2016-01-26 51 views
-3

我们正在使用jQuery表单插件(http://jquery.malsup.com/form/#getting-started)对服务器进行jquery ajax后调用。一旦我们得到了答复。jQuery语法使用ajax调用服务器上的脚本

我们需要解析它并在服务器上再做一次ajax调用。请让我知道使用jQuery调用此语法。

$('#MyForm').ajaxForm({ 
    success: function(data) { 
    console.log("My form submit successful.The response is >>" + data); 
    // Process this response and call another script on the server. 
    } 
}); 
+0

其正确。目前您面临的问题是什么? –

+0

'data'看起来像什么(JSON,HTML,blob ...)?你需要从第二个ajax调用什么,它的类型是什么(POST,GET)? –

+0

数据是一个json,第二个ajax也返回一个json。这是GET调用。 – JavaUser

回答

1

从回调函数中发出ajax请求如下所示:没什么特别的,没有什么不寻常的。

$('#MyForm').ajaxForm({ 
    success: function(data) { 
    console.log("My form submit successful.The response is >>" + data); 
    // Process this response and call another script on the server. 
    $.ajax({ 
     method: "GET", /*string "GET" or "POST"*/ 
     data: {}, /* query string or object with properties to pass to the server */ 
     url: "url.com", /* url of the next script */ 
     success: function() {/* success callback code */}, 
    }); 
    } 
}); 
0

添加在成功的函数另一个Ajax调用是这样的:

$('#MyForm').ajaxForm({ 
    success: function(data) { 
    console.log("My form submit successful.The response is >>" + data); 
    // Process this response and call another script on the server. 

    $.ajax({ 
     url: 'http://yourURL', 
     data: { 
     var: 'val', 
     .. 
     }, 
     type: 'POST', //GET 
     datatype: 'text', //XML,JSON 
     success: function(result) { 
     //result data handling 
     } 
     error: functionn() { 
     //error handling 
     } 
    }); 
    } 
}); 
相关问题