![](/img/trans.png)
[英]laravel 5 validation ajax rendering error response in javascript to show error in view
[英]Show Ajax error response as a webpage
从这样构建的Ajax调用中:
function GetData() {
$.ajax({
type: "POST",
url: "@Model.RouteForAjaxLastValue",//"/RCharts/AjaxMethod",//
data: "{Id: " + lastID+ "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
},
failure: function (response) {
alert(response.responseText);
},
error: function (response) {
alert(response.responseText);
}
})
我有时会收到这样的答复:
我可以看到这是要显示为网页,因为它的整个页面都是html格式的。
但是,有没有办法将其直接显示为新页面呢?
在我什至无法阅读错误可能之前,它会剪裁警报中的其余消息...
使用$("html").html(response.responseText);
在成功函数中。
success : function(response){
$("html").html(response.responseText);
}
您可能应该使用console.log()
但这应该附加到主体上:
$('body').append(response.responseText);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.