Note that there are some explanatory texts on larger screens.

plurals
  1. POPosting to ASMX Service and returning Object for jQuery
    text
    copied!<p>I am using fluent NHibernate with WebForms and I am trying to build a page where I allow a user to post a status update on their profile page and I a using a .asmx WebService to post the data to the database and then returnig a StatusUpdate instance to the page to be used by jQuery. I have a couple problems.</p> <p>1) First off when I return a string from the WebService(i was testing) the textbox where the user enters their status doesnt empty the contents. And since the page doesnt refresh even if I manally clear out the textbox and put in something else, it still posts the previous status to the database again. How do I fix this?</p> <p>2) Secondly, when I return the StatusUpdate Object from the Webservice I cant the results to display anything. Like I sad, Im using jQuery to make an AJX call to the WebService.</p> <p>Here is my code:</p> <p><strong><em>User Profile Page Javascript:</em></strong></p> <pre><code> var status1 = $("#statusBox").val(); var userID = $("#MainContent_userID").val(); function SetStatus() { $.ajax({ type: "POST", url: "http://localhost/Sports/Services/UserWebService.asmx/SetStatus", data: '{"status": "' + status1 + '", "userID": "' + userID + '"}', contentType: "application/json; charset=utf-8", dataType: "json", success: OnSuccess, error: OnError }); } function OnSuccess(response) { $("#statusBox").empty(); $("#MainContent_status").html(response.Status).fadeIn(1000); } function OnError(request, status, error) { alert(request.statusText); } </code></pre> <p></p> <p><strong><em>WebService:</em></strong></p> <pre><code>[WebService(Namespace = "Sports.Services")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] [System.Web.Script.Services.ScriptService] public class UserWebService : System.Web.Services.WebService { private IUserSession _userSession; public ISession Session1 { get { return NHibernateSessionModule.GetCurrentSession(); } } [WebMethod] public StatusUpdate SetStatus(string status, Guid userID) { _userSession = ObjectFactory.GetInstance&lt;IUserSession&gt;(); StatusUpdate update = new StatusUpdate(); update.StatusDateTime = DateTime.Now; update.StatusLikes = 0; update.UserID = userID; update.Status = status; Session1.SaveOrUpdate(update); return update; } } </code></pre> <p>Any help would be greatly appreciated... Ive looked at probably 100 pages trying to find an answer and none have worked..</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload