1

I have set up an Apache server running locally that hosts my web application (written in ExtJs). I have also a secon local server made with phantom.js and listening on port 8080 :

var server, service;

server = require('webserver').create();

service = server.listen(8080, function (request, response) {
    response.statusCode = 200;
    response.write('<html><body>Hello!</body></html>');
    response.close();
});

Now I'd like to do an Ajax request from my application to the phantom server :

Ext.Ajax.request({
    url: 'http://localhost:8080',
    method: 'GET',
    success: function(response){
        console.log('RESPONSE: ', response);
    },
    filure: function(response){
        console.log('failure: ', response);
    }
});

But when running this script I'm getting :

"NetworkError: 400 Bad Request - http://localhost:8080/?_dc=1336648497292" in the console. Does this operation violate the same origin policy ? Or is it something else ? Going to localhost:8080 shows the proper response, so the server is running properly.

mike_hornbeck
  • 1,612
  • 3
  • 30
  • 51

2 Answers2

2

your html is also on localhost:8080? If not (different port => different host) then you have the cross domain ajax problem.

Gavriel
  • 18,880
  • 12
  • 68
  • 105
0

Ajax doesn't work on File protocals!! It only works on HTTP or HTTP . I have found a course on udemy,mentors says ajax wont works on file:d://(path) protocals. So he shifted his files to web server and then he explained his topic on ajax.

hope this helps!

abdul riyaz
  • 80
  • 1
  • 1
  • 10