Your ajax code is working. Your server-side code is not working and is generating run-time error. You have said the same thing in your comment. 500 HTTP error code means that there was an error while running the code.
In your code, (In my opinion, the culprit is)
Convert.ToInt32(id)
In this code, if the
id
is not a valid integer. It would throw exception. Which is most likely to be a cause of this problem. The exception would be sent as an HTTP 500 status code. Thus terminating the execution and causing you too see as if "
Ajax code is not working".
Finally, 404's do not generate problems in requests. Unless you are downloading a resource which would terminate the downloading (
ever wondered why a broken image is shown?). Solution to this would be to debug the application. Set a break point to your function and run the application again and check your application's state.
For the above 500 problem, if the exception is raised at this line. Please read my recent answer in
this thread[
^]. It gives a solution for handling this error.
Edit
If the success function returns the
[object Object]
, then it is correct. This is the representation of the object in JavaScript. What you wanted to do was to act wisely on this object as a JSON object. Extract nodes and other members from this JSON object.