I am getting an error back on a jQuery ajax post.
The error I receive in IE is SyntaxError: Invalid character.
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.
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 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.
EDIT/ANSWER:
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.
Thanks!
The problem is in the web.config. I added the following httpModule in the web.config
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.
Thanks!