How to Call the REST API in jQuery and Obtain a Response

Asked 5 months ago, Updated 5 months ago, 27 views

I am currently writing a code to call the REST API from jQuery to retrieve the results.

[What I want to do]
 Use jQuery to access Paypal's following sandbox URL:

As for the result, the following string will be returned, so I would like to obtain it in jQuery.
 ACK = Failure & L_ERRORCODE 0 = 81002 & L_SHORTMESSAGE 0 = Unspecified %20 Method & L_LONGMESSAGE 0 = Method %20 Specified %20is %20 Not %20 Supported & L_SEVERITYCODE 0 = Error


I wrote the following code with reference to the above documentation, but I couldn't get the response string, so I ended up in the function of the error.

<!doctype html>
<html lang="ja">
    <title>jQuery REST API sample</title>
    <script type="text/javascript"src="./js/jquery-1.11.3.min.js"></script>
<h2>After retrieving PayPal data from the Rest API, use jQuary to view it</h2>

<h2>Read with $ajax</h2>
<ul class="ajax"></ul>
        type: 'GET',
        url: '',
        dataType: 'text'
                $(".ajax").append('<li><a href="'+text[i].link+'">'+text[i].title+'<a></li>');
            $('.ajax') .append(" Failed to load.");

Could someone please tell me what caused it?
Thank you for your cooperation.

jquery paypal ajax rest

2022-09-30 11:45

2 Answers

In principle, js cannot read files on other servers. (Cross Domain Problem)
It is possible to obtain information by php and so on and receive it by js.

JS: Cross-domain Ajax communication|ARTICLE|goma

2022-09-30 11:45

I'm sorry, but I think it's a fundamental problem with this question, but the endpoint of PayPal's REST API is


is called the NVP (classic) API. #api-operations

The REST API requests and responses remain the same as JSON.

That's all.

2022-09-30 11:45

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.