I am new to ASP. I want to make an ASP page that would return on request JSON formatted data. I followed a few tutorials and all i can see now is the link of a full fledged page with callbacks in my code. So in essence the server is ouptputting a lot of HTML which obviously is not valid JSON. So my only question is how do I go about making such a web page. I want my application to be designed such that when I go to a web page, say http://localhost:8080 (or something similar), a callback or a function in my C# code connects to the database, gathers some info and sends it back as the Response in valid JSON. I'm not looking for libraries which can achieve the same effect, but something like how do I achieve it by simply using a set of Response.Write statements.
Please pardon me if I may give the idea that I am not coherent with my concepts, because I'm really new to this entire thing.
Any help is greatly appreciated.
Regards, p1n3appl3
EDIT: I'm currently using the following JavaScript code:
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://localhost:47949/Default.aspx/NameChange");
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
alert(xhr.responseText);
}
}
xhr.send("");
It makes the call and all, everything's fine but the problem is that it returns the entire code of the "Default.aspx" page again. I mean, the method NameChange isn't even called (I've tested this by setting breakpoints).
What am I doing wrong?