0

Sorry for my bad english i has purchase API form (xe.com) 799$/Y

so now i using currency convert json with jquery my code

$('#rate-from, #rate-to').on('change', function(){
                    var from = $('#rate-from').val(),
                        to   = $('#rate-to').val();
                    $.post( 'https://xecdapi.xe.com/v1/convert_from.json/?from=' + from + '&to=' + to + '&amount=1', function( data ) {

                        console.log(data);
                    }, "jsonp");


                });

The json response

{"terms":"http://www.xe.com/privacy.php","privacy":"http://www.xe.com/legal/dfs.php","from":"USD","amount":1.0,"timestamp":"2015-11-17T18:00:00Z","to":[{"quotecurrency":"VND","mid":22455.9171363339}]}

and in my chrome browser get error

Uncaught SyntaxError: Unexpected token :?from=USD&to=VND&amount=1&callback=jQuery111307792251328937709_1447864663039&_=1447864663040:1

Why can i work with this json

Please help Thanks

Peter Jack
  • 847
  • 5
  • 14
  • 29

2 Answers2

0

Try to see another way to do this post, see this post for example, I holpe that can help you!

Community
  • 1
  • 1
0

You are getting this error because you are making a POST request and trying to send the parameters/data in the URL(query string). Either change the type of request to a GET request using the query string(some work will probably be needed on the API side for this), or restructure your request as a POST with your values in the body (relevant question)

Community
  • 1
  • 1
Danny H
  • 366
  • 2
  • 7