大家好,我有以下内容:
function sendUserfNotes()
{
$.ajax({
type: "POST",
url: '/pcg/popups/grabnotes.php',
data:
{
'nameNotes': notes_name,
},
success: function() {
}
});
}
我正在尝试将值 -notes_name 发送到 .php 文件,以便我可以使用 GET[''],但我收到一个奇怪的错误 - Uncaught TypeError: Illegal inspiration
notes_name 是根据是否单击链接在脚本底部定义的
代码:
$(document).ready(function () {
$(".NotesAccessor").click(function () {
notes_name = $(this).parent().parent().find(".user_table");
run();
});
});
run() 会触发 Jquery ui 中的一个对话框,并在我收到错误的地方运行此函数。
我不知道为什么会收到这个?
大卫
更新:
我认为这是将 JavaScript 值定义为“nameNotes”:notes_name 是在此代码之后定义的,但这并不重要。那么我该如何将 JavaScript 变量分配给它呢?
最佳答案
这是因为您将 jQuery 对象分配给 notes_name
,而不是字符串(或其他一些基本类型,如 int)。这会导致 $.ajax
调用失败。根据 .user_table
元素包含的内容,使用 .value()
或 .text()
(或类似的东西)来提取所需的字符串而不是使用 jQuery 对象。
关于php - $.ajax 问题 - 未捕获的 TypeError : Illegal invocation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14794037/