---
title: "ajax遇到的一点问题"
author: "squall140"
date: "2013-07-09T12:48:24Z"
tags: []
categories: ["Web前端"]
slug: "ajax"
draft: false
lastmod: "2013-07-09T12:48:19Z"
id: 1901850
url: "https://squall140.iteye.com/blog/1901850"
---

dex.html和a.html在同一目录结构下面，不过报错为：

XMLHttpRequest cannot load file:///D:/apache/Chapter6/ni/06/a.html.

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

 

**google一下，找到原因：**

ajax会对请求进行分析，比方说如果只是静态页面请求，那么地址均为 file://// ,相应的采取本地策略。对于chrome，则是出现XMLHTTPRequest 无法访问的问题。 

当把页面放置于服务器上，地址均为 http:// ，搞定

总结： AJAX 跨域访问导致的问题。

以后要注意了。