jquery classic asp返回HTML和recordcount/其他数据
使用经典ASP对返回HTML的ASP页面进行JQuery ajax调用。那很好。现在,我不仅要返回HTML,还要从我调用的页面返回一些数字,比如recordcount。我该怎么做 这是我的AJAX调用:jquery classic asp返回HTML和recordcount/其他数据,jquery,asp-classic,Jquery,Asp Classic,使用经典ASP对返回HTML的ASP页面进行JQuery ajax调用。那很好。现在,我不仅要返回HTML,还要从我调用的页面返回一些数字,比如recordcount。我该怎么做 这是我的AJAX调用: function sendCcbRequest(text) { var jsonToSend = { text: escape(text) }; var jsonToSend={ id: 1, lastname: escape(text) } ; $.ajax({ type: "POS
function sendCcbRequest(text) {
var jsonToSend = { text: escape(text) };
var jsonToSend={ id: 1, lastname: escape(text) } ;
$.ajax({
type: "POST",
url: 'test-ajax-handler.asp',
data: jsonToSend,
success: function(response) {
$('#output').append(response);
},
error: function() {
alert("error");
}
}); // end ajax
}
它调用的页面只是响应。写出一些HTML。我希望它也能输出一个计数。您可以让您的ASP页面在响应中发送一个自定义HTTP头,如:
XHR-Count: 5
与:
然后在success
回调中获取此标头:
$.ajax({
type: "POST",
url: 'test-ajax-handler.asp',
data: jsonToSend,
success: function(response, status, xhr) {
var count = xhr.getResponseHeader('XHR-Count');
alert(count);
$('#output').append(response);
},
error: function() {
alert("error");
}
});
以类似JSON的格式返回数据:
{"html":"<div>This is your HTML<\/div","count":3}
$.ajax({
type: "POST",
url: 'test-ajax-handler.asp',
data: jsonToSend,
dataType: "json",
success: function(response) {
$('#output').append(response.html);
$('#count').html(response.count);
},
error: function() {
alert("error");
}
});
{“html”:“这是你的html
{"html":"<div>This is your HTML<\/div","count":3}
$.ajax({
type: "POST",
url: 'test-ajax-handler.asp',
data: jsonToSend,
dataType: "json",
success: function(response) {
$('#output').append(response.html);
$('#count').html(response.count);
},
error: function() {
alert("error");
}
});