English 中文(简体)
Javagust XMLHttpRequest起步,从替代域名进入
原标题:JavaScript XMLHttpRequest breaks when accessed from alternate domain name

I have two domain names that point to my website, nathannifong.com, and uncc.ath.cx. Javascript on the site occasionally needs to pull down resources with XMLHttpRequest. All URLs of resources in client scripts refer to nathannifong.com, and when a user comes to the site by uncc.ath.cx, the scripts fail because of cross domain secuity policy in JavaScript.

我应作什么改动,使用户能够以任何域名进入该网站,但XMLHttpRequests仍在工作?

最佳回答

如果你利用URL中的域名提出“jax”要求,则将域名移至用户使用的域名,并且不会有交叉域问题。

问题回答

请看<代码>window. place,以确定网页的域,然后使用该域来装载请求? 这样,你就可以确保这一请求进入正确的领域。 你们还可以看看初等人物,但只能看GET的要求。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签