The following code is a very simple ajax call to server that alerts back on success and complete events.
From a reason I cannot understand on my development machine it works fins and alerts on success and complete but on server it never alerts on success. WHY ???
shtrudel
Member
461 Points
537 Posts
ajax call HELPPP
Apr 01, 2012 07:40 AM|LINK
Hi there,
The following code is a very simple ajax call to server that alerts back on success and complete events.
From a reason I cannot understand on my development machine it works fins and alerts on success and complete but on server it never alerts on success. WHY ???
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"></script> <script type="text/javascript"> function dummy() { $.ajax({ url: 'services/chatEngine.asmx/dummy', async: true, type: "POST", complete: function () { alert('Done'); }, success: function (a, b, c) { alert('Success'); } }); } </script> </head> <body> <form id="form1" runat="server"> <div> <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </ajaxToolkit:ToolkitScriptManager> <div id="userList">Users:<br /></div> <input id="Button3" type="button" value="dummy" onclick="dummy()" /> </div> </form> </body> </html>The server side dummy function returns nothing, code follows -
<WebMethod(True)> Public Function dummy() As String Return "" End FunctionKen Tucker
All-Star
16797 Points
2608 Posts
MVP
Re: ajax call HELPPP
Apr 01, 2012 10:40 AM|LINK
I suspect that when the deployed the url is wrong. You can use a tool like fiddler to monitor where the ajax call is going.
Space Coast .Net User Group
chetan.sarod...
All-Star
65839 Points
11163 Posts
Re: ajax call HELPPP
Apr 02, 2012 03:32 AM|LINK
function CallService() { var name = $("#taYourName").text();
//Also check whether you're getting the name before you call the webservice
// alert(name) $.ajax( { Type: "POST", contentType: "application/json; charset=utf-8", url: "YourNameIs.asmx/YourName", data: "{ 'yourName': '"+name+"' }", success: function (msg) { $("#lblForAjax").text(msg.d); } });
Check below url's you'll have idea..
http://dotnetslackers.com/articles/ajax/using-jquery-with-asp-net.aspx#consuming-a-web-service-using-asp-net-ajax
http://encosia.com/2008/06/05/3-mistakes-to-avoid-when-using-jquery-with-aspnet-ajax/
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
shtrudel
Member
461 Points
537 Posts
Re: ajax call HELPPP
Apr 04, 2012 05:25 AM|LINK
The solution for this headache follows -
Instead of: url: 'services/chatEngine.asmx/dummy',
I used: url: 'services/chatEngine.asmx?op=dummy',
Thanks for everyone