1

I am calling a rest service in ajax. If I add the svc file in the same project and call I am able to call the url

The below is the URL working

http://localhost:1947/GreenViewService.svc/?callback

If I add the svc in separate project layer and call in ajax I am unable to call it says 403 forbidden error and sometimes 405 error.

If I call the below url from different layer not working is it because port no. varies. should I give any access rights.

function GetDataPoints() {
            alert('S');
            var action = 'http://localhost:1984/GreenViewService.svc/?callback=';
            alert(action);
            $.ajax({
                "type": "GET",
                "url": action,
                "cache": false,
                "contentType": "application/json; charset=utf-8",
                dataType: "text",
                "success": function(result) {
                alert(eval(result));
                    var json = eval(result);
                    //fillDropDown(json, prefix + 'DataPoint', 'NodeLabel', 'ID');
                }
            });
        }
4

1 回答 1

0

正如您所说,它在同一个项目中有效,但在不同的项目中无效。

不同之处在于,当它在不同的项目中时,它是一个跨站点调用。

要进行跨站点调用,您需要使用JSONP

于 2011-05-14T21:22:54.570 回答