请求的资源上不存在'Access-Control-Allow-Origin'标头


    <!DOCTYPE html>
        <html>
            <head>
                <meta charset="utf-8" />
                <meta name="viewport" content="width=device-width, initial-scale=1" />
                <title>webservices example </title>
                <link rel="stylesheet" href="jquery.mobile-1.1.0.css" />
                <link rel="stylesheet" href="my.css" />
                <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
                <script type="text/javascript">
                    $(document).ready(function() {
                            $.ajax({
                                type:"GET",
                            url:"http://shoperola.com/Restaurant/foodysrest/sample",
                                 crossDomain: true,
                                 contentType: "application/json; charset=utf-8",
                                 dataType: "json",
xhrFields: {
       withCredentials: true
  },
             beforeSend: function (request) {
request.setRequestHeader("Access-Control-Allow-Origin: ", "*")
},
                                 success: function(data) {
                                                alert(data);
                                                },
                                 error: function(data) {
                                alert("Error in Processing-----" + data.status);
                                          }
                                });
                        });
                </script>
            </head>
        </html>

" XMLHttpRequest 无法加载 http://shoperola.com/Restaurant/foodysrest/sample?{}.请求的资源上不存在"访问控制允许源"标头。因此,不允许访问原产地'http://:8088'"。

您正在尝试对另一个域执行XMLHttpRequest(AJAX)

由于安全原因,这受到限制。

有关更多详细信息,请参阅:http://en.wikipedia.org/wiki/Cross-origin_resource_sharing

您在线缺少分号:

request.setRequestHeader("Access-Control-Allow-Origin: ", "*")

相关内容

最新更新