我正在开发一个系统.在该系统中,有一个添加项目到购物车功能.在该功能中,我使用的是Jquery $ .ajax.但在线服务器我遇到了这个错误 -
"XMLHttpRequest无法加载域名/ add_to_cart.php?item_id = 3&hotel_id = 2.请求标题字段X-Requested-With不允许使用Access-Control-Allow-Headers."
可以帮助我如何解决这个错误.
我正在使用这个jquery代码
$(document).on('click', '.ordering_btn', function(){
var item_id = $(this).data('value');
var hotel_id = "<?php echo $hotel_id; ?>";
$.ajax({
type: 'GET',
url: 'add_to_cart.php?item_id='+item_id+'&hotel_id='+hotel_id+'',
contentType: 'text/plain',
xhrFields: {
withCredentials: false
},
headers: {
"Access-Control-Allow-Headers": "X-Requested-With",
"X-Requested-With": "XMLHttpRequest"
},
success: function(data) {
$('#cart_msg').css('display', 'none');
$('#cart_item').html(data);
console.log(data);
},
error: function() {
}
});
});
Run Code Online (Sandbox Code Playgroud) 我有一个非常简单的重写规则。我的整个.htaccess文件如下:
RewriteEngine On
RewriteRule ^login/([a-zA-Z0-9-/]+)$ company-page.php?company_url=$1
RewriteRule ^login/([a-zA-Z0-9-/]+)/$ company-page.php?company_url=$1
Run Code Online (Sandbox Code Playgroud)
这可以在本地 Wamp 服务器上完美运行,但不能在在线服务器上运行。它显示以下错误。!
The requested URL /EZsample/login/mereco-technologies/ was not found on this server.
Run Code Online (Sandbox Code Playgroud)
谁能帮我!