AJAX InvalidStateError:试图使用对象不是,或不再,可用 [英] ajax InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable
问题描述
很奇怪的问题......我想多个值传递给后一个方法。它工作正常,只要我不张贴作为一个对象。但是,当我尝试后,我得到的错误对象
Very strange issue...I am trying to pass multiple values to a method in post. It works fine as long as I dont post as an object. But when I try to post as an object I get the error
未捕获InvalidStateError:试图使用对象不是,或不再,可用。
Uncaught InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable.
这里是code
本作品
var x = $('#myDiv').val(canvas.toDataURL("image/png", 1.0);
$.ajax({
type:'POST',
url:"/myMethod/test",
data: x,
success:function (response) {
}
});
但是,这是行不通的。
But this would NOT work
var x = $('#myDiv').val(canvas.toDataURL("image/png", 1.0);
$.ajax({
type:'POST',
url:"/myMethod/test",
data: {x:x},
success:function (response) {
}
});
我不知道为什么它是抱怨,当我试图把它作为一个对象发送
I am not sure why it is complaining when I try to send it as an object
推荐答案
这
var x = $('#myDiv').val(canvas.toDataURL("image/png", 1.0));
是一个jQuery集合DOM元素,如 VAL()
返回到该值时,得到的值设置的集合,一个字符串,而你设定值,至少它看起来像你,就算最后括号丢失了,你不能发送与阿贾克斯无论你怎么努力?
is a jQuery collection of DOM elements, as val()
returns the collection when a value is set, and a string when the value is gotten, and you're setting the value, at least it seems like you are, even if the last parenthesis is missing, and you can't send that with ajax no matter how hard you try ?
这篇关于AJAX InvalidStateError:试图使用对象不是,或不再,可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!