views:

41

answers:

2

I have the following javascript:

$.post("/Authenticated/DeletePage/" + PageId);
showStatus("Page deleted...", 10000);

I would like to instead pass showStatus() text that is returned by the $.post() call, rather than hardcoded text. How do I do this?

+3  A: 
$.post("/Authenticated/DeletePage/" + PageId, function(data){
   showStatus( data + " deleted...", 10000);
});

and for JSON

$.getJSON("/Authenticated/DeletePage/" + PageId, function(data){
   showStatus( data.pageName + " deleted...", 10000);
});
Andy
thank you for this.
splatto
A: 
$.post("/Authenticated/DeletePage/" + PageId, function(JSONdata) {
  showStatus(JSONdata.Name + " deleted...", 10000); //This is just to show you, signature is different
});

See jQuery documentation here: http://api.jquery.com/jQuery.post/

Dustin Laine
thank you for this.
splatto