AJAX versus CURL

前端 未结 3 748
执笔经年
执笔经年 2021-02-06 01:28

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

UPDATED: What I want to know i

3条回答
  •  盖世英雄少女心
    2021-02-06 02:04

    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, 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).

    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.

    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).

提交回复
热议问题