0

I created a project, it is an asp.net project and it has a Service1.asmx and ı hosted this project to remote server like a subdomain (myservice.test.com/Service1.asmx) and ı am calling this web service from an asp.net application with jquery ajax method. This application is on same remote server and ı hosted it like a subdomain (admin.test.com) when ı call admin.test.com/Default.aspx (this page uses web service abow) it is giving an error for this error ı looked with chrome console and it says: *(is not allowed by Access-Control-Allow-Origin.)*4444

GET_CAT_ALL: function (userId, callback, callback_err) {
    try {
        $.ajax({
            type: "POST",
            url: myservice.test.com/Service1.asmx + "/GET_CAT_ALL",
            data: "{userId:" + userId + "}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                if (msg.d == "0" || msg.d.length == 0 || msg.d == null) {
                    if (typeof callback == 'function') {
                        callback(null);
                    }
                }
                else if (msg.d <= 0) {
                    if (typeof callback_err == 'function') {
                        callback_err(msg.d, msg, 'GET_CAT_ALL');
                    }
                }
                else {
                    var _data = eval("(" + msg.d + ")");
                    if (typeof callback_err == 'function' && _data[0] != null && typeof _data[0].ErrorCode != 'undefined') {
                        callback_err(_data, msg, 'GET_CAT_ALL');
                    }
                    else if (typeof callback == 'function') {
                        callback(_data);
                    }
                }
            },
            error: function (msg) {
                if (typeof callback_err == 'function') {
                    callback_err(-1, msg, 'GET_CAT_ALL');
                }
            }
        });
    }
    catch (err) {
        if (typeof callback_err == 'function') {
            callback_err(-2, err, 'GET_CAT_ALL');
        }
    }
},
Suave Nti
  • 3,721
  • 11
  • 54
  • 78
Mehmet
  • 1,824
  • 3
  • 19
  • 28

1 Answers1

0

This means that your subject to the Cross Side restrictions put in place by your browser. Consider using JSONP if you can to try and get around this issue or if you can guarentee your users are using more up to date browsers you could get around it by using headers on your webserver. Have a look at the mozilla document about it.

John Mitchell
  • 9,653
  • 9
  • 57
  • 91