Mam dialog:

  1. onEdit: function(ev, elem) {
  2. var $elem = $(elem);
  3. $('#NoteDialog').remove();
  4. return $('<div id="NoteDialog""></div>').dialog({
  5. title: "Note Editor",
  6. resizable: false,
  7. modal: true,
  8. height: "300",
  9. width: "450",
  10. position: { my: "left bottom", at: "right top", of: elem},
  11. buttons: {
  12. "Save": function() {
  13. var txt = $('textarea', this).val();
  14. // Put the editied note back into the data area of the element
  15. // Very important that this step is included in custom callback implementations
  16. $elem.data("note", txt);
  17. $(this).dialog("close");
  18. },
  19. // "Delete": function() {
  20. // $elem.trigger("remove");
  21. // $(this).dialog("close");
  22. // },
  23. "Add Comment": function(e){
  24. var content = $('textarea').val();
  25. var user_name = $('#user-name').val();
  26.  
  27. var datetime_php = (function () {
  28. var list = [];
  29. $.ajax({
  30. url: "/sticky/getCurrentDateTime",
  31. type: "POST",
  32. dataType : "JSON",
  33. success: function(res) {
  34. list = res;
  35. }
  36. });
  37. return list;
  38. })();
  39. console.log(datetime_php );
  40.  
  41. $('.post-container').append('<div class="post" style="border-bottom: 1px solid black;margin-bottom: 10px; padding-bottom: 10px;"><p class="post-date">2014-11-15 10:40</p><p class="post-name">'+user_name+'</p><p class="post-content">'+content+'</p></div>');
  42. },
  43. Cancel: function() {
  44. $(this).dialog("close");
  45. }
  46. },
  47. open: function() {
  48.  
  49. //Get the note text and put it into the textarea for editing
  50. $(this).css("overflow", "hidden");
  51. var note = '';
  52. var form = '<form style="border-bottom: 1px solid black; padding-bottom: 10px;"><input type="text"></input><input type="submit" value="Add" /></form>';
  53. var content = '<div class="post-container" style="height: 60%; width:100%; overflow-y: scroll; padding-top: 15px;"><div class="post" style="border-bottom: 1px solid black;margin-bottom: 10px; padding-bottom: 10px;"><p class="post-date">2014-11-15 09:28</p><p class="post-name">Jan Kowalski</p><p class="post-content">zawartosc</p></div></div>';
  54. var textarea = '<textarea style="width: 100%; overflow: hidden; resize: none;"></textarea>';
  55. var name = '';
  56. var date = '';
  57. var html = $(form+content+textarea);
  58. $(this).html(html);
  59.  
  60. html.val($elem.data("note"));
  61. }
  62. });
  63. },

i kiedy probuje pobrac ajaxem date z phpa to js zwraca pusta tablice co robie nie tak ? Jakies pomysly?
PHP oczywiscie zwraca date.