I am new to Web Sevice, I am getting the following error when I tried to run my page (Local) in Chrome Console
ERROR
Failed to load resource: the server responded with a status of 405 (Method Not Allowed)
http://localhost:12015/myWebService.asmx?op=GetCategories
Here is the related code:
jQuery
$.ajax({
url: "http://localhost:12015/myWebService.asmx?op=GetCategories",
type: "POST",
------------
------------
success: function (data) {
var categories = data.d;
$.each(categories, function (index, category) {
category.CategoryId).text(category.CategoryName);
});
},
error: function (e) { //always executing 'error' only
alert("hello");
}
web service URL
http://localhost:12015/myWebService.asmx
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public List<Categories> GetCategories()
{
//code
}
Page URL
http://localhost:11761/Default.aspx
EDIT: The error gone when I just included dataType: 'jsonp'
But now there is another error.
Uncaught SyntaxError: Unexpected token <
:12015/myWebService.asmx?op=GetCategories&callback=jQuery183010907560377381742_1356599550427&{}&_=1356599550438:3
When I clicked the link(which was mentioned in the error), it is displaying the page. Then what could be the problem ? I dont know what the error means (and also which part of code to show). Please help.
Related