jQuery POST/GET in same function -


with function send data form external file:

function save() {   var data = $('#formid').serialize();   var url = 'test.php';   $.post(url, data, function (response) {     alert("good");   }); }  

in test.php save values witch take $_post, after inserting values make query db return me json. want take json data , push same jquery function beginning , show in div id="reza"

i try add $.get json response function , script is:

function save() {   var data = $('#formid').serialize();   var url = 'test1.php';   $.post(url, data, function (response) {     //----------this new part------     $.getjson("test.php", function(result) {       $.each(result, function(i, field) {         $("#reza").append(field.name);       });         });   }); }  

please me catch response data.

first give me tips first question on stackoverflow, solved problem, solution is:

function save() {     var data = $('#formid').serialize();     var url = 'test1.php';     $.post(url, data, function (response) {         $.each(response, function(i, field) {             $("#reza").append(field.name);         });         }); } 

i have wrong approach @ beginning, try json, don't need that. in solution take returned data function give me response (already in json) , go trough loop display it. hope someone, cheers!


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -