简体   繁体   English

使用ICallbackEventHandler处理多个请求

[英]Handle multiple requests with ICallbackEventHandler

Is there any way to make multiple requests to the callback function in asp.net when using the ICallbackEventHandler? 使用ICallbackEventHandler时,有什么方法可以向asp.net中的回调函数发出多个请求? I need the results for each result, however, when I iterate through and call the function, I get the result only for the last call. 我需要每个结果的结果,但是,当我遍历并调用该函数时,只能得到最后一次调用的结果。 Any way to make it return a result for each call? 有什么办法让它为每个调用返回结果?

This is what I am passing in via javascript: 这就是我通过javascript传递的内容:

    function NoPostback() {
        $(".spans").each(function(index, item) {
            CallServer($(item).attr("myattr"));
        });
    }

In this, myattr is a custom attribute that holds a value (1..10). 在这种情况下,myattr是一个自定义属性,其中包含一个值(1..10)。 What I want returned is something like ('you said: ' + id) to be returned for each of the calls, so that I can go ahead and place them in the appropriate holders. 我想要返回的是每次呼叫都返回的类似('您说:'+ id),以便我可以继续进行并将它们放置在适当的持有人中。

However, only one item is returned which is the final call made. 但是,仅返回一项,这是进行的最终调用。 For instance if there are 4 items, it returns only ('you said: 4'). 例如,如果有4个项目,则仅返回(“您说:4”)。

Any idea on how to have all of them returned? 关于如何全部归还的任何想法吗?

Thanks in advance. 提前致谢。

Most Javascript AJAX frameworks either abort any subsequent requests if one is in progress, or they ignore previous requests and only handle the latest. 大多数Javascript AJAX框架要么中止正在进行的任何后续请求,要么忽略先前的请求,仅处理最新的请求。 The AJAX request itself will pass through the browser's XmlHttpRequest object, but the rest of the javascript code is running within the pages thread. AJAX请求本身将通过浏览器的XmlHttpRequest对象传递,但是其余的javascript代码在页面线程中运行。 Currently, there is no concurrent programming with javascript (however this is slated to change .) 目前,尚无使用javascript的并发编程(但是,这将有所改变 。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM