TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Pranjal Vatsa
NA
1
3.5k
Ajax call to a web method does not give response
Aug 8 2013 7:49 AM
Hi,
I am calling a javascript method from the click of a link:
<a href="#" onclick="get_project_details('<%# Eval("projectIdentifier") %>');"><%# Eval("projectIdentifier") %></a>
The javascript:
<script type="text/javascript">
function get_project_details(project_identifier) {
$.ajax({
type: "POST",
url: "View.asmx/HelloWorld",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
sucess: OnSuccess,
failure: OnError
});
}
function OnSuccess(data, status) {
alert(data.d);
}
function OnError(request, status, error) {
alert(request.statusText);
}
</script>
As you can see, the Ajax call is to a web method HelloWorld() which is inside an asmx page:
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
I do not get a response from the web method. When I try to debug the method by putting a break point, I see that the method is being 'hit'.
But the problem is that the response does not go back to the javascript function. I dont even get an error (OnError() does not give a result).
I tried inspecting the 'onclick' element from the browser and no help from there as well.
Am I missing some settings somewhere. Any kind of help is greatly appreciated.
Regards,
Pranjal
Reply
Answers (
1
)
POST Request in JQuery
insert href in javascript grid