hi all.
I am trying to make a call on a webservice by javascript/ajax, when both files are on my localmachine it is working fine, but when i move the webservice to another server it is not working.
can any one please help., I would appriciate with some code. this is my code:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="js/cordova.js"></script> <script src="js/jquery-1.6.4.min.js"></script> <script src="js/jquery.js"></script> <script src="js/jquery.mobile-1.0.min.js"></script> <script > function initPage() { document.addEventListener("deviceready", HellowWorld, false); } function HellowWorld() { $.ajax({ type: "POST", url: "http://myWebSite.com/ws.asmx/HelloWorld", data: "{}", crossDomain: true, contentType: "application/json; charset=utf-8", dataType: "json", cache: false, success: OnSuccess, error: OnError }); } function OnSuccess(data, status) { $('#lblResult').html(data.d); } function OnError(request, status, error) { alert("an error has occured..!" + request.statusText + error); } </script> </head> <body onload="initPage()"> <label id="lblResult"></label> </body> </html>
and the webservice is :
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; [WebService(Namespace = "http://myWebSite.com/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. [System.Web.Script.Services.ScriptService] public class ws : System.Web.Services.WebService { public ws () { } [WebMethod] public string HelloWorld() { return "Hello World Example"; } }