I am new to Web Sevice, I am getting the following error when I tried to run my page (Local) in Chrome Console
ERROR
try this
[WebMethod]
[ScriptMethod(UseHttpPost = true)]
public List<Categories> GetCategories()
{
//code
}
or edit web.config
<system.web>
...
<webServices>
<protocols>
<add name="HttpSoap"/>
<add name="HttpPost"/> -->
<add name="HttpGet"/>
<add name="Documentation"/>
<add name="HttpPostLocalhost"/>
</protocols>
</webServices>
...
</system.web>
Refer http://codeclimber.net.nz/archive/2006/12/22/How-to-enable-an-ASP.NET-WebService-to-listen-to-HTTP.aspx
I added a simple line on my friend's suggestion above the jquery ajax call
jQuery.support.cors = true;
Now it is working fine :)
ONLY IN IE BROWSER
I would be happy to know if it can be solved using different way as it is not recommended.
Anyhow I asked this question again after many efforts and I got different error which was solved in this post here
make your content type as "application/json; charset=utf-8", as follows
$(document).ready(function() {
$.ajax({
type: "POST",
url: "RSSReader.asmx/GetRSSReader",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
// Hide the fake progress indicator graphic.
$('#RSSContent').removeClass('loading');
// Insert the returned HTML into the <div>.
$('#RSSContent').html(msg.d);
}
});
});
also refer link
Add Allow Access All Origin In The Server Side
in my case it was failing becasue of there was not POST method in servet, but I had GET method.
so I jsut changed the type:"GET", so it is working now.