Perform curl request in javascript?

后端 未结 3 1028
谎友^
谎友^ 2020-12-02 09:56

Is it possible to send a curl request in jQuery or javascript?

Something like this:

curl \\
-H \'Authorization: Bearer 6Q************\' \\
\'https:/         


        
3条回答
  •  醉话见心
    2020-12-02 10:43

    Yes, use getJSONP. It's the only way to make cross domain/server async calls. (*Or it will be in the near future). Something like

    $.getJSON('your-api-url/validate.php?'+$(this).serialize+'callback=?', function(data){
    if(data)console.log(data);
    });
    

    The callback parameter will be filled in automatically by the browser, so don't worry.

    On the server side ('validate.php') you would have something like this

    'failed'));
    ?>
    

提交回复
热议问题