Please help me to solve the following.
There is the client side code to get JSON data from my server:
<input type="button" id="btn" value="btn" />
<script type="text/javascript">
$('#btn').click(function () {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
data: "{'em':'1'}",
url: "http://myserver/default.aspx/GetInfo",
dataType: "json",
success: function (result) {
$.each(result, function (i, field) {
alert(field);
});
}
});
});
</script>
And there is the aspx page on my server with the code:
[System.Web.Services.WebMethod]
public static string GetInfo(string em)
{
return "{\"a\":\"" + em + "\"}";
}
The task is to create the web method on my aspx page placed on my server for the client to get JSON data to him. When I test it locally it works but when I call web method from the server it doesn't. I know that I should change client code to work with cross-domains but how i should do it when I have web method on server side?