我正在使用来自 ajax 调用的 post 方法调用 vbscript 页面,作为返回,我们从 vbscript 页面获取 html 数据。 ajax 中是否存在任何函数,我们可以使用它在浏览器上加载该 html 响应,就像我们在 vbscript 中执行 Response.Write 一样。 我搜索了几乎所有可能的解决方案,但没有找到任何相关的内容。您的小小帮助将不胜感激。
Ajax Function :
<script type="text/javascript">
function ajaxcallforstatus() {
$.ajax({
type : "POST",
url: "http://someURL",
dataType : "application/json",
data : $("#status1").val().trim(),
statusCode:{
401:function (data) {
$("#status1").val(data.responseText);
},
400: function (data) {
$("#status1").val(data.responseText);
},
200:function (data) {
alert(data.responseText);
},
500:function (data) {
$("#status1").val(data.responseText);
}
}
});
}
</script>
注意:当我们获得状态 200 时,我们要在浏览器上加载 html 响应(data.responseText)。
最佳答案
你可以在 jquery 中尝试 .load
$(element).load('path of the file')
或者你可能需要 jquery 中的 .html
$(element).html('html code here');
关于javascript - 如何使用ajax调用在浏览器上加载html响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31801669/