Google App Engine with Ajax: Test the returned data -


i used use following ajax code html element <a class="getcontent" href="/content">...</a>:

$('.getcontent').click(function() {    var url = $(this).attr('href');    $('#content').load(url);    return false;  }); 

if refresh whole page depending on value returned server:

$('.getcontent').click(function() {    var url = $(this).attr('href');   if (url == "success") {     document.location.reload(true);   }else{     $('#content').load(url);   }   return false;  }); 

of course, if part hypothetical. working on google app engine python, server-side script may be:

if ...:   self.response.out.write('success') else:   render(self, 'some_html_file.html') 

how how do it? thanks.

try:

var menuid = $("ul.nav").first().attr("id"); var request = $.ajax({   url: url, //your url here   type: "post",   data: {id : menuid},   datatype: "html" });  request.done(function(msg) {   $('#content').html( msg ); });  request.fail(function(jqxhr, textstatus) {   //reload here }); 

source: http://api.jquery.com/jquery.ajax/


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -