jQuery $.post 返回“超出最大调用堆栈大小"; [英] jQuery $.post returning "Maximum call stack size exceeded"
本文介绍了jQuery $.post 返回“超出最大调用堆栈大小";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 jquery 中执行 ajax post 时出现堆栈大小超出错误
Getting a stack size exceeded error doing an ajax post in jquery
$('#challengeForm').submit(function(e) {
var ajaxUrl = admin.ajax_url;
var emailInput = $(this).find('input[name="email"]');
var formId = $(this).find('input[name="formId"]');
$.post(ajaxUrl,{action:'challengeFormSubmit',email:emailInput,listId:formId},function(data) {
console.log(data);
},'json');
e.preventDefault();
});
我运行了一些 console.log
调试,发现在 $.post
处调用了错误.
I ran some console.log
debug and found the error is called at the $.post
.
推荐答案
您应该使用值(而不是对象):
You should use the values (not the objects):
$('#challengeForm').submit(function(e) {
var ajaxUrl = admin.ajax_url;
var emailInput = $(this).find('input[name="email"]').val();
var formId = $(this).find('input[name="formId"]').val();
$.post(ajaxUrl,
{
action:'challengeFormSubmit',
email:emailInput,
listId:formId
},
function(data) {
console.log(data);
},
'json'
);
e.preventDefault();
});
这篇关于jQuery $.post 返回“超出最大调用堆栈大小";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文