[英]trying to put an ajax request inside the success call back of another ajax request
I am trying to make two jQuery ajax calls, the second should be made from the success callback of the first. 我正在尝试进行两个jQuery ajax调用,第二个应该从第一个的成功回调中进行。 I have tried a couple variations of code eg just messing with the brackets.
我尝试了几种代码变体,例如只是弄乱了括号。
Here is what I tried. 这是我尝试过的。
$.ajax({
url: 'inc/grab_talk.php?name='+encoded_name+'&loc='+encoded_address+'&lat='+encoded_lat,
type: 'post',
success: function () {
$.ajax({
url: 'inc/talk_results.php',
type: 'post',
success: function (dat) {
alert(dat);
}
});
}
});
I am receiving '500 (internal server error) in console 我在控制台中收到'500(内部服务器错误)
Try this, you can use either POST or GET, but in your case GET seems to be more appropriate. 尝试此操作,可以使用POST或GET,但是在您的情况下,GET似乎更合适。
$.ajax({
type: "GET",
url: "some.php",
data: { name: "somename", location: "somelocation" },
success: function(){
$.ajax({
type: "GET",
url: "someother.php",
success: function(){
alert('test');
}
});
}
});
Check this example 检查这个例子
$.ajax({
type: "post",
url: "ajax/example.php",
data: 'page='+btn_page,
success: function(data){
$.ajax({
var a=data; //edit data here
type: "post",
url: "example.php",
data: 'page='+a,
success: function(data){
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.