2016-01-26 49 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 
     } 
    }); 
    } 
}); 
相關問題