87,992
社区成员
发帖
与我相关
我的任务
分享function submit(obj, url) {
if ($(obj).is_validate()) {
var post = $(obj).serialize();
$.ajax({
type: "POST",
url: $(obj).attr("action"),
cache: false,
data: post,
success: function (data) {
alert(data);
if (data.substr(0, 1) == '{') {
data = jQuery.parseJSON(data);
if (data.state == 1) {
$.dialog({
message: data.message,
timeout: data.timeout || 3,
type: "success",
close_handler: function () {
if (url) {
location.href = url
} else {
window.location.reload(true);
}
}
});
} else {
$.dialog({
message: data.message || "操作失败",
timeout: data.timeout || 3,
type: "error"
});
}
} else {
$.dialog({
message: '操作失败',
timeout: 3,
type: "error"
});
}
}
})
}
return false;
}stringvar.substr(start [, length ])
stringvar是字符串 而你的data是数组吧