我想向PHP页面发送"Fire and Forget"查询

Bri*_*ter 0 html php asp.net http

我正在为客户实现各种PHP和ASP.NET Web应用程序.

我想安装一个非常低开销的用户跟踪系统.(它必须在Intranet上,这只是一个内部系统).

我想做类似以下的事情:

line 1  normal code
line 2  normal code
line 3  Send Request/Query/Info to http://internal-IP/userTracker.php?Name=UserName&Page=...
line 4  Code that proceeds immediately after line 3 without waiting for a reply of any sort. 
Run Code Online (Sandbox Code Playgroud)

"火和忘记"似乎是这里最好的比喻.

有小费吗?

谢谢!

the*_*edz 6

这几乎是AJAX的教科书案例.从本质上讲,您将启动该URL的rqeuest,并继续正常执行代码.

这是jQuery中的一个示例(假设您要发布到URL).其他图书馆可能不同.正如这样做没有任何js lirbaries.

 //some code
 $.get("http://internal-IP/userTracker.php?Name=UserName", function() {
    //put something here if you want to verify the request worked.
 });
 //some more code
Run Code Online (Sandbox Code Playgroud)

浏览器将触发请求,"更多代码"将继续执行而不会阻止请求.