post JSON data to Odata with Jquery
I have a html file with this code:

     <form>
            <label>Subject</label>
            <input id="subject" />
            <br/>
            <label>Username</label>
            <input id="userID" />
            <br/>
            <label>Category</label>
            <input id="categoryID" />
            <br/>
        </form>
        <button id="btnAdd">Add task</button>
        
        <script type="text/javascript">
             $("#btnAdd").click(function () {                    
                // Convert the form into an object 
                var data = { Subject: $("#subject").val(), Category: $("#categoryID").val(), Username: $("#userID").val() }; 
                 
                // JSONify the data 
                var data = JSON.stringify(data);
                               
                // Post it 
                $.ajax({ 
                    type: "POST", 
                    contentType: "application/json", 
                    url: "http://localhost:8888/TaskerInsert.svc/Tasks", 
                    data: data,
                    dataType: "json", 
                    success: insertCallback,
                    error:function(XMLHttpRequest, textStatus, errorThrown) {
                debugger;
                alert("error");
            }

                }); 
            }); 
          
         
            function insertCallback(result) { 
                // unwrap result 
                var newTask = result["d"]; 
          
                // Show primary key 
                alert("Movie added with primary key " + newTask.TaskID); 
            } 
        </script>

I also have a WCF data service wich is really simple

    public class TaskerInsert : DataService<Models.TestTaskEntities>
    {
        // This method is called only once to initialize service-wide policies.
        public static void InitializeService(DataServiceConfiguration config)
        {
            // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
            // Examples:
            config.SetEntitySetAccessRule("*", EntitySetRights.All);
            // config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
        }
    }




When I browse to the URL, everything works fine, but clicking the button, the error function fires. When using firebug I the only thing I get is this:

XML Parsing Error: no element found Location: moz-nullprincipal:{c5fef865-5fe6-4b1f-83d0-ddba3d7ff4e9} Line Number 1, Column 1:
post JSON data to Odata with Jquery
===

I have a html file with this code:

     <form>
            <label>Subject</label>
            <input id="subject" />
            <br/>
            <label>Username</label>
            <input id="userID" />
            <br/>
            <label>Category</label>
            <input id="categoryID" />
            <br/>
        </form>
        <button id="btnAdd">Add task</button>
        
        <script type="text/javascript">
             $("#btnAdd").click(function () {                    
                // Convert the form into an object 
                var data = { Subject: $("#subject").val(), Category: $("#categoryID").val(), Username: $("#userID").val() }; 
                 
                // JSONify the data 
                var data = JSON.stringify(data);
                               
                // Post it 
                $.ajax({ 
                    type: "POST", 
                    contentType: "application/json", 
                    url: "http://localhost:8888/TaskerInsert.svc/Tasks", 
                    data: data,
                    dataType: "json", 
                    success: insertCallback,
                    error:function(XMLHttpRequest, textStatus, errorThrown) {
                debugger;
                alert("error");
            }

                }); 
            }); 
          
         
            function insertCallback(result) { 
                // unwrap result 
                var newTask = result["d"]; 
          
                // Show primary key 
                alert("Movie added with primary key " + newTask.TaskID); 
            } 
        </script>

I also have a WCF data service wich is really simple

    public class TaskerInsert : DataService<Models.TestTaskEntities>
    {
        // This method is called only once to initialize service-wide policies.
        public static void InitializeService(DataServiceConfiguration config)
        {
            // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
            // Examples:
            config.SetEntitySetAccessRule("*", EntitySetRights.All);
            // config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
        }
    }




When I browse to the URL, everything works fine, but clicking the button, the error function fires. When using firebug I the only thing I get is this:

XML Parsing Error: no element found Location: moz-nullprincipal:{c5fef865-5fe6-4b1f-83d0-ddba3d7ff4e9} Line Number 1, Column 1: