0

I have web api deployed to IIS, it works fine when called via browser like: http:// localhost /api/products response is in XML.

But however when i call it via Ajax it doesn't work. Google Chrome returns the following error:

. origin null is not allowed by Access-Control-Allow-Origin.

$(document).ready(function () {
        var url = 'http://localhost/api/products';
        $.get(url, function (data) {
            $("#test").append(data[5].prod);

        });
    });

any idea what could be wrong?

Thanks

Raju Kumar
  • 1,235
  • 3
  • 21
  • 38

2 Answers2

0

Have you followed the advice here XmlHttpRequest error: Origin null is not allowed by Access-Control-Allow-Origin.

Community
  • 1
  • 1
GraemeMiller
  • 11,733
  • 7
  • 54
  • 108
0

For cross domain requests, you should make a jsonp ajax request

Fisch
  • 3,725
  • 1
  • 26
  • 38