简体   繁体   中英

no data from callback, jquery ajax json, php, amazon

I've been trying the code at: https://gist.github.com/Exeu/4674423 this is a code that connects to amazon wsdl and retrieve product information. so far I have not been able to make it work. The code consist of a index.html, ama_funtion.js, search.php, AmazonECS.class.php. The index file loads and you insert the item name you want choose the category and other params, then when you click in the search link it goes to the ama_function.js and it make and ajax request to the search.php which have the passwords and keys to connect to the wsld, then it request the info from Amazon and return it as JSON to ama_function.js.

I have test ama_funtions.js to see if the index.html file connects to it, and it does, I did put an alert to show the input in the search box at index.html. Also I have test the search.php, I have manualy put the values in the search.php file and it connects to amazon and retrieve the product information as JSON object. the problem is that there is not a success callback as no data return to ama_funtions.js from search.php to be rendered. I know this as I tested it by adding an error function

$.ajax({
      url: "search.php",
      dataType: 'json',
      type: 'GET',

              error: function () {
                  alert("NO DATA");
              },

and it did show me the alert, also I have tried to change the ->

data: "q="+value+"&category="+cat+"&country="+country+"&page="+page,

for ->

data: {
          q : value,
          category : cat,
          country : country,
          page : page }

nothing works I am crazy looking to solve this, I will appreciate someone that help us with this. Please see a working example which belong the person sharing the code -> http://amazonecs.pixel-web.org . This is the way is suppose to work but it doesn't.

Regards

$.ajax({
    url: "search.php",
    dataType: 'json',
    type: 'GET',

    error: function () {
        alert("NO DATA");
    },

    data: "q="+value+"&category="+cat+"&country="+country+"&page="+page,

    data: {
        q : value,
        category : cat,
        country : country,
        page : page 
    }
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM