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
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
Post a Comment