【问题标题】:Jquery Ajax show Uncaught SyntaxError Unexpected token : [closed]Jquery Ajax 显示未捕获的 SyntaxError 意外令牌:[关闭]
【发布时间】:2014-06-30 21:41:50
【问题描述】:

我的应用程序基于 spring mvc。在我的 html 页面上,我使用 jquery ajax 将数据发送到服务器。但它显示了一些错误。 那就是它显示 dataType : 'json' 符号 : 是意外的

$(document).ready(function() {
        $('#decision').click(function(e) {  
            type : 'POST',
            dataType : 'json',
            url : '/RealEstate/ChangeStatus.html',
            data : ({
            id : $("#pid").val()

            });
        });

});

【问题讨论】:

  • 这是什么data : ({
  • 请阅读有关jQuery.ajax() 方法的文档。你这里的代码是非常错误的

标签: jquery ajax spring-mvc


【解决方案1】:

这些属性应该在 AJAX 方法中,而不是直接在点击事件处理程序中。

您的请求应如下所示:

$('#decision').click(function(e) {
    $.ajax({
        type : 'POST',
        dataType : 'json',
        url : '/RealEstate/ChangeStatus.html',
        data : {id : $("#pid").val()}
    });
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-25
    相关资源
    最近更新 更多