-4

我想要一个用于多个 ajax 请求的代码。实际上发生的是我的第一个 ajax 请求给了我响应,并且在该响应函数中我调用了另一个具有另一个网站 url 的函数。我想使用多个 ajax 请求将数据发送到这个新网站。

请帮帮我...谢谢, Prafulla

4

1 回答 1

0

use global variables and manipulate your data in each request. like:

var a;
$.ajax({
    url:url_one;
    success: function(data){ a =data; }
});

$.ajax({
    url:url_two;
    data: a //sends the data from the 1st request
    success: function(data){ 
        //do something with the data from the 2nd url
     }
});

You can encapsulate your ajax call in function or event handlers as you need. You can also manuipulate the data returned in variable a before sending it to the 2nd url. Seems sloppy to me, but sould work.

于 2012-10-27T07:29:51.080 回答