I would like to make an ajax call to a different server (same domain and box, just a different port.) e.g.

My page is


I would like to make a ajax get request to:


I am getting this error:

Access to restricted URI denied (NS_ERROR_DOM_BAD_URI) 

I know that you can not make an ajax request to a different domain, but it seem this also included different ports? are there any workarounds?

+4  A: 

Have a certain page on your port 80 server proxy requests to the other port. For example:


Note the url encoding on the last query string argument value.

Joseph Bui
+1  A: 

You could use JSONP. This is where you specify a callback with the request, the response from your ajax request gets wrapped with the callback function name. Rather than using XmlHttpRequest you insert a tag into the HTML document with the URL. Then when the response is retrieved the callback function is called, passing the data as a parameter.

Check this blog post out for an example

Luke Smith

This is a browser restriction. All javascript calls must be to the same server and port of the home of the script. This will require something server-side to get around. I.E. have the process at localhost forward the request to localhost:7076.


It sucks, but it's necessary... Basically what you're going to need to do is proxy your AJAX request through a local proxy - some server side script / page / whatever on the same domain you're on - receive the call and forward it on to the other resource server-side. There might be some IFRAME tricks you could do but I don't think they work very well...could be wrong though, been awhile.