I am new to web service. In my project, I connected Web Service(everything is ready-made) now when I tried to run I got the below error.
ERROR -->
Uncaught SyntaxError: Unexpected token <
The Web service and my page are in same solution but different projects.
The related code is as follows:
jQuery (URL: 11761)
function GetAllCategories() {
$.ajax({
url: "http://localhost:12015/myWebService.asmx?op=GetCategories",
type: "POST",
dataType: "jsonp",
data: "{}",
contentType: "application/jsonp; charset=utf-8",
success: function (data) {
var categories = data.d;
$.each(categories, function (index, category) {
alert(category.CategoryId);
});
},
error: function (e) {
alert(e.message);
}
});
}
Web Service (URL: 12015)
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public List<Categories> GetCategories()
{
//Code
}
Before asking here I have gone through this link(cant understand it)
EDIT:
Got alternative answer from this post.
See Question&Answers more detail:os