jquery - Display notification message onsave data to DB in MVC4 VB.NET using razor -
i need display notification messge user when click save button on page. save button phone call click event in jquery , calling ajax function within event. in ajax phone call calling action method in controller httppost method. when info posted info returning integer value( 1 success, 0 failure). based on need display message user.how ?
$("#btnsave").click(function (e) { var vcomments = $("#ddlcomments :selected").text(); $.ajax({ url: "/acc/save", type: "post", data: vcomments, success: function (data) { }, error: function (ex) { alert(ex.responsetext); } }); });
controller:
<httppost> function save(byval comments string) actionresult dim result int32 = save(comments) if result = 1 'i need display notification saying posted else ' need display notification "unable post" end if end function
after thinking (and varying original comment) suggest taking advantage of httpstatuscoderesult
in action:
<httppost> function save(byval comments string) actionresult dim result int32 = save(comments) if result = 1 homecoming new httpstatuscoderesult(204) ' 204 successful, no content else homecoming new httpstatuscoderesult(500) ' error, internal server end if end function
now can rely on error
, success
callbacks display appropriate message.
jquery vb.net asp.net-mvc-4
No comments:
Post a Comment