AJAX与CURL [英] AJAX versus CURL

查看:230
本文介绍了AJAX与CURL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要知道请求的来源,我需要了解CURL(在PHP中)和AJAX(在Javascript中)之间的区别。

I need to know the difference between CURL (in PHP) and AJAX (in Javascript) when it comes to know Source of the request.

已更新:
我想知道的是,如果我正在使用AJAX生成请求,将以数据包作为源在服务器端接收到哪个发件人IP地址?与CURL相同,对于所有用户,它将发送一个IP地址。但是,JS是否也是这种情况? JS在客户端执行,因此它是客户端IP地址吗?

UPDATED: What I want to know is if I am generating requests using AJAX what sender IP address would be received at the server side with the packet as source? The same is with CURL and for all users it will single ip address be sent. But is that the same case with JS? JS executes at the client side so would it be client IP address?

推荐答案

cURL是服务器端进程。这意味着它将在页面呈现之前被调用,并且与客户端的功能无关。

cURL is a server-side process. This means that it will be called before the page is rendered and has nothing to do with the client's capabilities.

AJAX是客户端调用。这意味着它不会被执行,直到客户端加载页面为止(或者至少看到并执行了那段代码,但这通常适用于document.ready)。

AJAX, however, is a client-side call. This means that it will not be executed until the client loads the page (or at least that piece of code is seen and executed, but this typically works on document.ready).

如果您希望检索信息并将其立即转储给用户,那么cURL是您的最佳选择。如果您想进行渐进式加载(转储页面,然后检索内容以对用户进行无缝加载),那么AJAX是最好的选择。始终牢记,尽管在当今这个时代是半琐碎的事,但在FireFox的NoScript扩展的情况下,AJAX可能会被禁用。

If you're looking to retrieve the information and dump it to the user immediately then cURL is your best bet. If you'd like to do a progressive load (dump the page, then retrieve the content for a "seamless" load to the user) then AJAX is the best bet. All th while keep in mind, though in today's day and age it's semi trivial, AJAX may be disabled in cases of FireFox's NoScript extension.

cURL执行将在服务器上。 AJAX请求的来源将基于每个客户端。两者都不提供安全的检测方法(服务器端),以知道谁发送了什么(因为标头可以更改)。

That being said, the source of the cURL execution will be on the server. The source of the AJAX request will be on a per-client basis. Neither of which provide a secure means of detection (server-side) to know who sent what (as headers can be altered).

这篇关于AJAX与CURL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆