I have the following web service;
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
It's stock standard with no alterations to the class decorators.
I have this jQuery method;
var webMethod = "http://localhost:54473/Service1.asmx/HelloWorld";
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
data: "{}",
dataType: "json",
url: webMethod,
success: function(msg){ alert(msg.d); },
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
}
});
It's a post action because later on I need to post data to it.
When I execute the jQuery I get a "No transport" error returned.
One thing I should also mention is that the jQuery is stored in a simple HTML file on my machine and the WebService is running on my machine also.
There is no code behind on the HTML page it's simply a web page and not a c# project or anything.
Can anyone please point me in the right direction here?
I too got this problem and all solutions given above either failed or were not applicable due to client webservice restrictions.
For this, I added an iframe in my page which resided in the client;s server. So when we post our data to the iframe and the iframe then posts it to the webservice. Hence the cross-domain referencing is eliminated.
We added a 2-way origin check to confirm only authorized page posts data to and from the iframe.
Hope it helps