How i can use only 1 ajax function in my code, which will return data only when ajax finish.
Example:
var Jurl = json.php, Jdata='one:AAA';
jsonRet = json(Jurl, Jdata);
if(jsonRet) {
$('body').prepend(data);
} else {
Jurl = anotherJson2.php;
Jdata='one:BBB';
jsonRet2 = json(Jurl,Jdata);
if(jsonRet2) {
...
}
}
json(Jurl, Jdata) {
$.getJSON(Jurl, {Jdata} , function(data) {
if(data ==='finish') {
return false;
} else {
return data;
}
}
But, i cant use this code, i must create some another (one more) function with jsonRet2. So the code will be not optimize... I want maximum less code.