admin管理员组文章数量:1400024
My ajax call hits the controller and fetches a plete JSP page on success. I was trying to load that data independently on a new page rather than within some element of the existing page. I tried loading it for an html tag but that didn't work either. I tried skipping the success function but it remained on the same page without success data. My ajax call is made on clicking a normal button in the form and the code looks like as shown below.
$.ajax({
url : '/newpage',
type : 'POST',
data : requestString,
dataType : "text",
processData : false,
contentType : false,
success : function(pleteHtmlPage) {
alert("Success");
$("#html").load(pleteHtmlPage);
},
error : function() {
alert("error in loading");
}
});
My ajax call hits the controller and fetches a plete JSP page on success. I was trying to load that data independently on a new page rather than within some element of the existing page. I tried loading it for an html tag but that didn't work either. I tried skipping the success function but it remained on the same page without success data. My ajax call is made on clicking a normal button in the form and the code looks like as shown below.
$.ajax({
url : '/newpage',
type : 'POST',
data : requestString,
dataType : "text",
processData : false,
contentType : false,
success : function(pleteHtmlPage) {
alert("Success");
$("#html").load(pleteHtmlPage);
},
error : function() {
alert("error in loading");
}
});
Share
Improve this question
asked Jun 24, 2015 at 4:37
Android MasonAndroid Mason
4691 gold badge7 silver badges17 bronze badges
7
-
2
Why don't you use
window.location.href = '/newpage';
to redirect to the page? – Cymen Commented Jun 24, 2015 at 4:40 -
two questions: 1. did you see the
alert("Success")
? 2. could you please add your html code, specially#html
part? – Mehdi Commented Jun 24, 2015 at 4:46 - have you ever HEARD about LINKS? – madalinivascu Commented Jun 24, 2015 at 4:49
-
this is not how you use
.load()
, please read the jQuery API doc again – Rick Su Commented Jun 24, 2015 at 4:52 - On success Redirect the page – Vishal Patel Commented Jun 24, 2015 at 4:53
2 Answers
Reset to default 2This should do:
$.ajax({
url : '/newpage',
type : 'POST',
data : requestString,
dataType : "text",
processData : false,
contentType : false,
success : function(pleteHtmlPage) {
alert("Success");
$("html").empty();
$("html").append(pleteHtmlPage);
},
error : function() {
alert("error in loading");
}
});
You can try this,
my_window = window.open("");
my_window.document.write(pleteHtmlPage);
into your success.
本文标签: javascriptLoad ajax success data on new pageStack Overflow
版权声明:本文标题:javascript - Load ajax success data on new page - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744235300a2596528.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论