I have a click event on Jquery, I am getting arrays with help of $.ajax and post, after that I am calling another procedure in a loop . Second procedure has a $.ajax too , is it allowed ? My script seems not working, I dont know what would wrong ?
Just give me any hint or clue please
And feel free to ask any questions
code :
$("#list").click(function(){
var ptext ="";
$.ajax({
type: "POST",
url: "phpname.php",
data: ({
newtask: "grab"
}),
dataType: "json",
success: function(data){
$.each(data, function(key, value) {
ptext=value.name;
parseclick(ptext);
});
}
});
});
});
function parseclick(ptext)
{
$.ajax({
type: "POST",
url: "phpname.php",
data: ({
grab_ads : "grab",
list_url : ptext
}),
dataType: "html",
success: function(msg){
$("#all_name").append(msg);
var part= msg.split("#url#");
$("#current_num").val(part[0]);
}
});
});
}
Yes, it’s allowed. But if you make an Ajax call in your second precedure without the asynchronously option set to false, the loop will create a bunch of Ajax calls at the same time without waiting for a response from your server.
edit: After you added an example, I can see too many closed brackets.