我试图在下面的上下文中为数组使用一个拼接函数,但是页面只是在发送表单后更新。请问这里有什么机构吗?
submitHandler: function(form) {
a = JSON.stringify($(form).serializeArray()); // a = [{"name":"1","value":"1"},{"name":"2","value":"2"},{"name":"3","value":"3"},{"name":"4","value":"4"},{"name":"5","value":"5"},{"name":"6","value":"6"}];
a.splice(1, 4);
var jqxhr = $.ajax({
type: "POST",
beforeSend: function() {
console.log("beforeSend" + a);
},
...
您可以尝试这样:
var _array= $(form).serializeArray();
_array.splice(1, 4);
submitHandler: function(form) {
a = JSON.stringify(_array); // a = [{"name":"1","value":"1"},{"name":"2","value":"2"},{"name":"3","value":"3"},{"name":"4","value":"4"},{"name":"5","value":"5"},{"name":"6","value":"6"}];
var jqxhr = $.ajax({
type: "POST",
beforeSend: function() {
console.log("beforeSend" + a);
},