I know there are a few questions, but I tried a lot of them, and I still can't even get my script to make it on the server. Here is what I have now:
Javascript
function UpdateSessionUser(user) { if (user != null) { var targetPage = "http://" + document.location.host + "/Sitefinity/Services/Sandbox/SessionUsers.asmx/UpdateSessionUser"; var dataText = { "jsonUser" : JSON.stringify(user) }; try { $.ajax({ type: "POST", url: targetPage, data: dataText, contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { alert(response.d); return true; }, failure: function (msg) { alert(msg); return false; } }); } catch (err) { alert(err); } } }
Custom Object Example
Object BaseID: "fe85149c-71f2-4c61-b7c6-a00300e2f84e" HasChanged: true IsReferralReceived: false IsReferralRequired: true IsSeatApproved: true Name: "Miles" ReferralFromUser: null ReferralFromUserID: null ReferralReceivedBy: null ReferralReceivedByUserID: null ReferralReceivedOn: "/Date(-62135578800000)/" RegisteredOn: "1330281960000" SeatApprovedBy: null SeatApprovedByUserID: null SeatApprovedOn: "/Date(-62135578800000)/" SeatNumber: "2" SessionID: "d0773d5e-aeeb-4b9c-b606-0a564d6c5845" UserID: "6af2fd9e-b4b6-4f5a-8e9c-fe7ec154d4e5" __type: "SandboxClassRegistration.SessionUserField.ClientSessionUser"
FROM#
[WebMethod] public bool UpdateSessionUser(object jsonUser) { return SessionUserHelper.UpdateSessionUser(new ClientSessionUser(jsonUser)); }
Why does my JSON call never hit the server? I set a breakpoint at the very beginning of the function (before returning) so that I can look at the parameter of the jsonUser object, but it never does it there.
All I get in return is an error:
POST http: // localhost: 60877 / Sitefinity / Services / Sandbox / SessionUsers.asmx / UpdateSessionUser 500 (Internal server error)
--- UPDATE
Here is the final result (I had to “pull” the object and then send the final data file). Webservice method has not changed
function CallWebServiceToUpdateSessionUser(target, user) { var dataText = { "jsonUser": JSON.stringify(user) }; $.ajax({ type: "POST", url: target, data: JSON.stringify(dataText), contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { alert(response.d); return true; }, failure: function (msg) { alert(msg); return false; } }); }