0

Using Extjs 3.4. I have a simple ajax request:

 Ext.Ajax.request({
    url: "localhost:3000/offers.json",  
    success: function(response, opts) {
      var obj = Ext.decode(response.responseText);
      console.dir(obj);
   },
   failure: function(response, opts) {
      console.log('server-side failure with status code ' + response.status);
   }
});

The localhost:3000/offers.json is a Rails 4 back-end and it works fine:

$curl localhost:3000/offers.json              
[{"id":1,"desc":"a description","img_link":"www.google.come","product_link":"www.google.come","code":"927341","price":"20.29","special_price":"13.99","saving":"31.0","created_at":"2014-06-23T15:45:11.404Z","updated_at":"2014-06-23T15:45:11.404Z"}]

So the back-end si working.

When i call the json url from my Ext.Ajax.request I have this error in Chrome console:

OPTIONS localhost:3000/offers.json net::ERR_UNKNOWN_URL_SCHEME ext-base.js:21
i ext-base.js:21
Ext.lib.Ajax.k.request ext-base.js:21
Ext.extend.request ext-all-debug.js:4636
ajaxSearch_function grid-ajax.js:8
Ext.Button.Ext.extend.onClick ext-all-debug.js:31872
h ext-all-debug.js:5215
server-side failure with status code 0 

Ideas?

user1066183
  • 2,444
  • 4
  • 28
  • 57

1 Answers1

0

If you are making a cross domain call from Ajax , Ajax wont support it.

You have to use JsonP.It is useful when you want to load data from other domain .

Once check this example and try to implement the same in your code.

http://try.sencha.com/touch/2.0.1/docs/Ext.data.JsonP.1/viewer.html

Hope this helps..

Sreek521
  • 669
  • 4
  • 9