Diz*_*igh 0 javascript forms ajax jquery
我正在调用另一个ajax页面,该调用发布了一个json对象.我还需要从表单发送数据(不使用提交 - 我将ajax调用附加到使用的按钮e.preventDeault()
).
电话如下:
var myUrl = 'sendswatch-data.php';
$.ajax({
url: myUrl,
data: {'swatchid[]':swatchArray}, 'formdata':$('#orderData').serialize()},
type: "POST",
error: function(xhr, statusText, errorThrown){
// Work out what the error was and display the appropriate message
},
success: function(myData){
$('#tabsampleorder').html(myData);
$('.tabber').hide();
$('#tabsampleorder').show();
}
});
Run Code Online (Sandbox Code Playgroud)
我在formdata的页面ID上有一个表单.
如何发送此以及json对象?我试过了
data: {'swatchid[]':swatchArray}, 'formdata':$('#orderData').serialize()},
Run Code Online (Sandbox Code Playgroud)
但那会产生错误.
watchArray之后你有一个额外的}.尝试删除它.
data: {'swatchid[]':swatchArray, 'formdata':$('#orderData').serialize()},
Run Code Online (Sandbox Code Playgroud)