ajax IE parsererror,jQuery为ajax请求返回“parserror”

Been getting a "parsererror" from jquery for an Ajax request, I have tried changing the POST to a GET, returning the data in a few different ways (creating classes, etc.) but I cant seem to figure out what the problem is.

My project is in MVC3 and I'm using jQuery 1.5

I have a Dropdown and on the onchange event I fire off a call to get some data based on what was selected.

Dropdown: (this loads the "Views" from the list in the Viewbag and firing the event works fine)

@{

var viewHtmls = new Dictionary();

viewHtmls.Add("data-bind", "value: ViewID");

viewHtmls.Add("onchange", "javascript:PageModel.LoadViewContentNames()");

}

@Html.DropDownList("view", (List)ViewBag.Views, viewHtmls)

Javascript:

this.LoadViewContentNames = function () {

$.ajax({

url: '/Admin/Ajax/GetViewContentNames',

type: 'POST',

dataType: 'json',

data: { viewID: $("#view").val() },

success: function (data) {

alert(data);

},

error: function (data) {

debugger;

alert("Error");

}

});

};

The above code successfully calls the MVC method and returns:

[{"ViewContentID":1,"Name":"TopContent","Note":"Content on the top"},

{"ViewContentID":2,"Name":"BottomContent","Note":"Content on the bottom"}]

But jquery fires the error event for the $.ajax() method saying "parsererror".

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值