Guest User

Untitled

a guest
Jan 22nd, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. Does not work:
  2.  
  3. function reloadForm() {
  4. jQuery.ajax({
  5. url: "<generate_form_url>",
  6. type: "GET",
  7. complete: custom_function_with_js_in_response()
  8. });
  9. };
  10.  
  11. $('#link_form').ajaxComplete(function() {
  12. custom_function_with_js_in_response();
  13. });
  14.  
  15. $(document).ready(function() {
  16.  
  17. $('#obj').click(function() {
  18.  
  19. $.ajax({
  20. url: "<url>"
  21. }).done(function() {
  22. do_something_here();
  23. });
  24. });
  25.  
  26. $(document).ready(function() {
  27.  
  28. $('#obj').click(function() {
  29.  
  30. $.ajax({
  31. url: "<url>",
  32. success: function(data){
  33. do_something_with(data);
  34. }
  35. })
  36. });
  37.  
  38. // undefine the function before the AJAX call
  39. // replace myFunc with the name of the function to be executed on complete()
  40. myFunc = null;
  41.  
  42. $.ajax({
  43. ...
  44. complete: function() {
  45. runCompleteCallback(myFunc);
  46. },
  47. ...
  48. });
  49.  
  50. function runCompleteCallback(_func) {
  51. if(typeof _func == 'function') {
  52. return _func();
  53. }
  54. setTimeout(function() {
  55. runCompleteCallback(_func);
  56. }, 100);
  57. }
  58.  
  59. $('.log').ajaxComplete(function(e, xhr, settings) {
  60. if (settings.url == 'ajax/test.html') {
  61. $(this).text('Triggered ajaxComplete handler. The result is ' +
  62. xhr.responseHTML);
  63. }
  64. });
  65.  
  66. function reloadForm() {
  67. jQuery.ajax({
  68. url: "<generate_form_url>",
  69. type: "GET",
  70. complete: custom_function_with_js_in_response
  71. });
  72. };
Add Comment
Please, Sign In to add comment