我试图加载我的网站使用jQuery的远程内容,但我不断地得到一个错误:如何使用jquery将远程内容加载到对话框中?
XMLHttpRequest cannot load 'anylink_here' Origin null is not allowed by Access-Control-Allow-Origin.
这里是我的代码:
jQuery(function(){
$('#checkout').submit(function(e){
//prevent default behavior and hide possibly existing pop-up
e.preventDefault();
//process request
var form = this;
var url = form.action;
var dialog = $('<div id="lightbox_dialog"></div>').appendTo('body');
// load remote content
dialog.load(
url,
function (response, status, xhr){
dialog.html(response);
});
dialog.dialog();
//prevent the browser to follow the link
return false;
});
});
和一个表单代码:
<form id="checkout" action='http://me.me/' method='get'>
<input type="image" class="class1" onclick="this.form.action='http://en.wikipedia.org/wiki/Sample'" title="Title" value="" src="http://4cornersautoloan.com/images/SmallButton.gif">
</form>
我也需要为同一个域做它,但是从http到https。
看到这个主题,我相信:http://stackoverflow.com/questions/4106993/ajax-cross-sub-domain-requests – 2010-11-18 16:27:15
这里:http://stackoverflow.com/questions/4142779/ help-getting-getting-json-format-data-from-external-website/4142817#4142817 – 2010-11-18 17:59:49
and here:http://stackoverflow.com/questions/3828982/xmlhttprequest-cannot-load-an-url-with-jquery – 2010-11-18 20:12:30