jQuery的AJAX后使用asp.net [英] jQuery AJAX Post using asp.net
问题描述
我得到一个错误回一个jQuery AJAX职位。
I am getting an error back on a jQuery ajax post.
我收到IE的错误是语法错误:无效的字符
The error I receive in IE is SyntaxError: Invalid character.
整个项目可以在这里找到/ A>
The entire project can be found at: http://dragsort.codeplex.com/
当你移动一个箱子到另一个位置(单击并拖动)阿贾克斯后发生。
When you move one of the boxes to another location (click and drag) the ajax post occurs.
为了显示错误,我不得不错误AJAX属性添加到jQuery的AJAX调用。
In order to display the error I had to add the error ajax property to the jQuery ajax call.
function saveOrder() {
var data = $("#gallery li").map(function() { return $(this).attr("itemID"); }).get();
$.ajax({
url: "example.aspx/SaveListOrder",
data: '{ids:["' + data.join('","') + '"]}',
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
error: function(data, status, jqXHR) { alert(jqXHR); }
});
};
背后的方法code
Code behind Method
[WebMethod]
public static void SaveListOrder(int[] ids)
{
for (int i = 0; i < ids.Length; i++)
{
int id = ids[i];
int ordinal = i;
//...
}
}
这是什么问题任何想法?先谢谢了。
Any ideas on what the issue is? Thanks in advance.
编辑/回答:
问题是在web.config中。我添加了以下HTTP模块在web.config
The problem is in the web.config. I added the following httpModule in the web.config
<configuration>
<system.web>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
</system.web>
</configuration>
如果有人想阐述一下为什么这是需要的将是巨大的。我将创建一个岗位作为答案,一旦我被允许这样做。
If anyone would like to elaborate on why this is needed that would be great. I'll create a post as the answer once i'm allowed to do so.
谢谢!
推荐答案
问题是在web.config中。我添加了以下HTTP模块在web.config
The problem is in the web.config. I added the following httpModule in the web.config
<configuration>
<system.web>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
</system.web>
</configuration>
如果有人想阐述一下为什么这是需要的将是巨大的。我将创建一个岗位作为答案,一旦我被允许这样做。
If anyone would like to elaborate on why this is needed that would be great. I'll create a post as the answer once i'm allowed to do so.
谢谢!
这篇关于jQuery的AJAX后使用asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!