0

i'm trying to get some data as json from cs-cart API so in the browser when i call some data like this

user name : admin@example.com
password : j58O9J11085SBycaDKMY1C75k1998rup

http://demos.cs-cart.com/54bbdcef36bac/api/payments 

it get the requested data but when i try call this data from $.ajax nothing happening

first i create an HTML page

<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>  

    <div id='#div1'></div>

    <script type="text/javascript" src="./jquery-2.1.1.min.js" ></script>
    <script type="text/javascript" src="./GetData.js" ></script>
      </body>

</html>

and in the GetData.js

$(function(){
   $.ajax({
            type: 'GET',
            url: 'http://admin%40example.com:j58O9J11085SBycaDKMY1C75k1998rup@demos.cs-cart.com/54bbdcef36bac/api/payments',
            dataType: 'jsonp',

            success:function(result){
              console.log(result);
              $("#div1").html(result);  
            }
        });
        });

and no data is retrieved and there is no errores to so what should i do to retrieve the data from the json file thank for any help in advance.

UPDATE:

it give this error whene add s to http so it give GET https://admin%40example.com:j58O9J11085SBycaDKMY1C75k1998rup@demos.cs-cart.…ayments?callback=jQuery211009486119472421706_1421614338422&_=1421614338423 net::ERR_CONNECTION_REFUSED

why jquery add parameter

?callback=jQuery211009486119472421706_1421614338422&_=1421614338423 net::ERR_CONNECTION_REFUSED

to the url

UPDATE

it now get the json but in the response as .js file and when i try to console.log the data nothing happening

$(function(){
       $.ajax({
                type: 'GET',
                url: 'https://fadi40%example.com:j58O9J11085SBycaDKMY1C75k1998rup@demos.cs-cart.com/54bbdcef36bac/api/payments',
                dataType: 'jsonp',

                success:function(data){
                 console.log(data);

                }
            });
            });
Fadi
  • 2,320
  • 8
  • 38
  • 77
  • 1
    real user name and password? wow! – u_mulder Jan 18 '15 at 20:12
  • it just a demo :D user name and password – Fadi Jan 18 '15 at 20:12
  • 1
    I think Same origin policy prevents queriyng another domain. – u_mulder Jan 18 '15 at 20:14
  • i try to debug this and it give this error any help on what to do http://admin%40example.com:j58O9J11085SBycaDKMY1C75k1998rup@demos.cs-cart.c…/payments?callback=jQuery2110734999023610726_1421613108206&_=1421613108207 – Fadi Jan 18 '15 at 20:34
  • How do you know there are no errors? – ron tornambe Jan 18 '15 at 20:34
  • i see the console on chrome and there is no error but i try different console and give me the error in the previous comment – Fadi Jan 18 '15 at 20:37
  • `ERR_CONNECTION_REFUSED` seems clear enough, and it adds the callback parameter because you told it to make a JSONP request. Go and read the Wikipedia page about JSONP if you want to know how it works (which you should do before trying to use it) – Quentin Jan 18 '15 at 21:01
  • ok no problem but if i use just JSON it give me XMLHttpRequest cannot load http://demos.cs-cart.com/54bbdcef36bac/api/payments. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. How can i get the json or how can i add the Access-Control-Allow-Origin to in jquery – Fadi Jan 18 '15 at 21:16

0 Answers0