是Ajax调用不堵,什么是他们的寿命?他们的、寿命、Ajax

2023-09-10 19:17:04 作者:用生命在耍帅

我觉得ackward问因为我并不很新的网页开发这些基本问题。但我想仔细检查我的假设仍...

I feel ackward asking these fundamental questions given that I am not exactly new to web development. But I want to double-check my assumptions nevertheless...

我建立了独特的形象意见记录在我的应用程序。当用户(不是机器人)访问的图像页面,Ajax调用由一个后台进程,它收集的会话信息,比较了重复和存储访问。我有我的所有的JavaScript引用,以及这个调用在HTML的底部,就在< /身体GT; 元素:

I'm building the recording of unique image views in my application. When a user (not a bot) visits an image page, an Ajax call is made to a back-end process that collects the session info, compares for duplications and stores the visit. I have all my javascript references as well as this call at the bottom of the HTML, just before the </body> element:

$.get(basepath + "image/1329/record/human", function(data){
console.log("Data Loaded: " + data);
});

默认情况下,调用$。获得由异步的。然而,我想测试以下假设:

By default, the call to $.get is made asynchronous. Yet I want to test the following assumptions:

是不是正确的,这种方法可以确保调用视图录制脚本是无阻塞的用户界面的其他部分? 是不是正确的,因为后端脚本将完成一次调用,而不管用户是否导航到另一个网页?

推荐答案

根据 jQuery的。获得引用 ..

此的[$。获得()的的简写的Ajax功能,相当于的:

This [$.get()] is a shorthand Ajax function, which is equivalent to:

$.ajax({ url: url,   data: data,  
         success: success,   dataType: dataType
});

和$。阿贾克斯是异步的(也就是非阻塞)在默认情况下,这就是Ajax中的一种手段。

And $.ajax is asynchronous (i.e. non-blocking) by default, that's what the A in Ajax means.

此外,后端服务器code开始在服务器收到请求的时刻,然后独立客户端停留在页面上或不运行,除非实现某种机制,以停止正在运行的服务,我想你没有。

Also, back-end server code is started in the moment the server receives the request and then runs independently of the client staying on the page or not, unless you implement some kind of mechanism to stop the running service which I suppose you did not.

上帝保佑!