javascript - How to properly return HTML when doing AJAX -


i new using ajax , not think doing things correctly. page work fine , intended not think getting result in proper way. have page loads , display table gets ajax call. sends in couple parameters pagination purposes gets correct records page on.

javascript

$(document).ready(function()      {      var offset = document.getelementbyid('offset').value;     var sortdirection = "";     var sorttype = "";      if (document.getelementbyid('setsortname').value != ""){         sorttype = document.getelementbyid('setsortname').value;     }      if (document.getelementbyid('setsortdirection').value != ""){         var sortdirection = document.getelementbyid('setsortdirection').value;     }       $.get("ajaxdistributormanage.php", { offset: offset, sortdirection: sortdirection, sorttype: sorttype},       function(html) {          $("#distributortable").append(html);          var resort = true;          $("table").trigger("update", [resort]);       });              return false;     }  ); 

ajax page

http://pastebin.com/f3gs4qqe

i couldn't format on directly on stack on flow put on paste bin.

so if can tell me how should doing or point me toward tutorials on that'd awesome. have looked around online , seems ajax advice differs

jquery ajax , it's shortcut methods $.get, $.post, etc. 'best guess' content type returned.

see: https://api.jquery.com/jquery.get/

you can overwrite best guess if necessary.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

oracle - Changing start date for system jobs related to automatic statistics collections in 11g -