views:

326

answers:

5

I am using JQuery to post with AJAX to another ASP page. Do I need this ASP page to return a full html page. Or can I just have it send back a value ( I just need a status ) . Here is my function.

 $.ajax({
   url: "X.asp",
   cache: false,
   type:  "POST",
   data:  queryString,
   success: function(html){
     $('#x_'+Num).append(html);
   }
 });
+14  A: 

If it's just a simple value you need, I'd simple use Json (JQuery has a dedicated method for that : $.getJSON()).

So no, you don't need your ASP page to return a full html page, just the value in simple JSON notation.

Berzemus
COMMANDER KEEN! Nice!
theraccoonbear
+1  A: 

You can return anything you want (even single character), but remember to change content type of your page X.asp to ContentType="text/plain" if you don't want to return HTML.

Marek Blotny
+1  A: 

Well, the whole point of AJAX is IMHO that you don't need to return the whole page. The server just sends the simple answer that you need.

Rene Saarsoo
+1  A: 

You can return anything from the backend, I personally prefer JSON, but you have to specify the dataType property in your $.ajax options

Ahmad
A: 

Using AJAX, you can return anything, even binary data. Although it was designed for XML, you can use it for anything you can transfer across a web server. However, HTTP Requests are expensive, so don't abuse them too much!

Malfist