jquery - Get entire html page as response with javascript -


i doing ajax post specific page either can id response if went expected or random html page , http 400 response if went wrong. in error case want open entire html page in new window. have tried following not working - sets variable data [object object] instead of intended html page.

$.ajax({     type: "post",     url: posturl,     data:'message=' + message + '&' + 'title=' + title,     statuscode: {             400:function(data) {                 var newwin = open('','windowname','height=300,width=300');                 newwin.document.write(data);         },     },     success: function(json) {         alert("post success");     },     error: function(jqxhr, textstatus, errorthrown) {         alert("error connecting page.");     } }); 

specify datatype : 'html' , change success function variable. example:

$.ajax({     type: "post",     datatype: 'html',     url: posturl,     data:'message=' + message + '&' + 'title=' + title,     statuscode: {             400:function(data) {                 var newwin = open('','windowname','height=300,width=300');                 newwin.document.write(data);         },     },     success: function(html) {         alert("post success");         $("#mydiv").html(html);     },     error: function(jqxhr, textstatus, errorthrown) {         alert("error connecting page.");     } }); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

java - Using an Integer ArrayList in Android -