API: Curl or Cross Ajax Request | SoloLearn: Learn to code for FREE!

+3

API: Curl or Cross Ajax Request

Hey guys! At the moment I am working on a big web project and I have to build an API. Normally I use Curl request to get data from an API but I just found out that other sites often use direct cross ajax request to the API domain. Do you know the advantages and disadvantages of each possibility? Would be very interesting!:)

2/19/2018 9:42:31 PM

saschacode

1 Answer

New Answer

+3

Cross domain AJAX request are stopped by browsers due to security issues so you have to Allow cross AJAX request from your API if your api is consumed by other website with jQuery. You can also use jsonp for making cross domain request, What is JSONP and how to use it in jQuery & JavaScript - http://www.yogihosting.com/jquery-jsonp-example/