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,255
  • 3
  • 21
  • 39

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,973
  • 8
  • 57
  • 111
0

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

Fisch
  • 3,775
  • 1
  • 27
  • 38