Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery classic asp返回HTML和recordcount/其他数据_Jquery_Asp Classic - Fatal编程技术网

jquery classic asp返回HTML和recordcount/其他数据

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

使用经典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: "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");
    }
});