English 中文(简体)
“利用JQuery ajaxForm()在IE8上被否认有错误
原标题:"Access is denied." error on IE8 using JQuery .ajaxForm()

祝贺所有人,

I m a AJAX newbie, and I m with a problem with same origin policy protection using JQuery 1.4.4 and the jquery. 表格。

I have an AJAX contact form which works fine so long as visitors preface URL s they type in with "www". But if they navigate to my site (not using www), the URL still resolves OK but the URL doesn t match what I use in my AJAX form. In Chrome, this results in a console error:

http://www.example.com/“rel=“nofollow”http://www.example.com/rel=“nofollow”http://example.com 不允许查阅-Control-Allow-Origin。

而且,我获得的是“拒绝就业”。 因此,即使“URL”与“www”一起或没有“www”的K决心,如果访问者用“www”做前言的话,我的“非洲复兴开发银行”表格就赢得了工作。 如果我把我的日本宇宙航空研究开发机构法典改为。 然后,如果访问者去www.example.com,就会打赢笔工作。 我不能想一下,如何使我的法典处理这两种情况。 这必然是一个几乎每个人都会进入使用阿富汗武装部队的人的问题,而不管他们是否使用日本食品。 因此,我必须失踪。 请允许我就此对我进行教育? 我的测试守则如下。

感谢

Northk

<!DOCTYPE html> 
<html>
<head> 
<meta charset="utf-8"> 
<title>ajaxForm Error Test</title> 
<script src="http://www.example.com/js/jquery-1.4.4.min.js"></script> 
<script src="http://www.example.com/js/jquery.form.js"></script>    
</head> 
<body>
<form id="contact-form" method="post" action="http://this-url-wont-be-used.com/">
<a href="#" id="contact-button">SEND</a>
</form>
<script>
//
// hook up the form to ajax
//
$( #contact-form ).ajaxForm({
    url:  http://www.example.com/ , // forcing the URL doesn t seem to help!
    success: function(data) {
        alert(data);
    },
    dataType:  html 
});
//
// make the SEND link behave as if it s a submit button
//
$( #contact-button ).click(function(e) {
  $( #contact-form ).submit();
});
</script>
</body>
</html>
最佳回答

www.xyz.com和xyz.com这两个领域并不相同,因此,如果你在 Java稿档案中编造硬编码的urls的话,你就错了。

The short answer is ot use relative urls rather than full urls. You don t show actual urls so I can t give you an exmaple in your case but lets say the the domain was http://www.xyz.com and you need to post the form to the url http://www.xyz.com/admin/form/

In your javaScript the url you d use is /admin/form

That way no matter what url your visitor uses to get to your site it will work and it won t result in a cross domain scripting error.

当然,如果贵网站是公开的,你可能(永久)将Xyz.com网站转至www.xyz.com网站。 由于谷歌和其他搜索引擎认为这两个领域不同,你的网页将分两部分。

问题回答

尝试使用相对途径url: / ,





相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签