Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/446.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.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
Javascript POST请求:返回状态报告_Javascript_Jquery_Ajax_Asp.net Mvc - Fatal编程技术网

Javascript POST请求:返回状态报告

Javascript POST请求:返回状态报告,javascript,jquery,ajax,asp.net-mvc,Javascript,Jquery,Ajax,Asp.net Mvc,我有几个谷歌表单,我正在其中一个表单中寻找一个值 用户输入查找值,然后在服务器上以MVC操作处理搜索: 客户端 function findKPI() { var lookedUpValue = $('#lookedUpValue').val(); var sheetIDArray = getSheetIDArray(); var payload = { sheetIDArray: sheetIDArray, lookedUpValue: lookedUpValue }

我有几个谷歌表单,我正在其中一个表单中寻找一个值

用户输入查找值,然后在服务器上以MVC操作处理搜索:

客户端

function findKPI() {
    var lookedUpValue = $('#lookedUpValue').val();
    var sheetIDArray = getSheetIDArray();
    var payload = { sheetIDArray: sheetIDArray, lookedUpValue: lookedUpValue }
    $.post('GetValueSheet', payload)
        .done(function (data) { alert("OK") })
        .fail(function (data) { alert("Error: " + data.responseText) })
}
和服务器端:

<HttpPost>
Function GetValueSheet(sheetIDArray As List(Of String), lookedUpValue As String) As ActionResult
    Dim API As New GoogleAPI(Web.HttpContext.Current.Request.PhysicalApplicationPath + "APIKey.json")
    Dim ValuesList As List(Of String)
    For Each sheetID In sheetIDArray
        ValuesList = API.getValuesList(sheetID)
        If ValuesList.Contains(lookedUpValue) Then Return Json(sheetID)
    Next
    Return Json(Nothing)
End Function

函数GetValueSheet(sheetIDArray作为列表(字符串),lookedUpValue作为字符串)作为ActionResult
Dim API作为新的GoogleAPI(Web.HttpContext.Current.Request.PhysicalApplicationPath+“APIKey.json”)
尺寸值列表为列表(字符串)
对于sheetID阵列中的每个sheetID
ValuesList=API.getValuesList(sheetID)
如果ValuesList.Contains(lookedUpValue),则返回Json(sheetID)
下一个
返回Json(无)
端函数
有大量的纸张需要处理,可能需要一段时间

我想了解是否以及如何向客户发送中间结果,以显示10%和50%等的工作表已经处理。


感谢您的帮助

Post请求是一个离散事务,因此您不能直接执行。我可以这样做的方式是公开一个API点,该API点采用标识事务的唯一键,当查询该API点时,它会发回一个显示查询状态的响应


以非api方式进行,您可以尝试使用WebSocket,它允许客户端和服务器之间的双向通信

您可以在Http委托中添加“GetNumberOfSheets”方法。然后您可以处理processbar客户端。