我在一个有购物车脚本的页面上得到一个错误。
Error: 'Ajax Error: Edit the path in jcart.js to fix.'
这个问题,据我所知,是围绕文件的相对路径。我已经尝试了各种各样的方法来获得正确的路径,但无济于事。
该错误特定于JavaScript文件jcart.js中的文件路径位置变量。文件的位置如下:
文件/目录:
- domain.com/folder/jcart/js/jcart.js
- domain.com/folder/jcart/config-loader.php
- domain.com/folder/jcart/relay.php
var JCART = (function() {
// This script sends Ajax requests to config-loader.php and relay.php using the path below
// We assume these files are in the 'jcart' directory, one level above this script
// Edit as needed if using a different directory structure
var path = 'jcart',
container = $('#jcart'),
token = $('[name=jcartToken]').val(),
tip = $('#jcart-tooltip');
var config = (function() {
var config = null;
$.ajax({
url: path + '/config-loader.php',
data: {
"ajax": "true"
},
dataType: 'json',
async: false,
success: function(response) {
config = response;
},
error: function() {
alert('Ajax error: Edit the path in jcart.js to fix.');
}
});
return config;
}());
change var path = 'jcart'
, to var path = 'folder/jcart'
,
由于实际的ajax请求将被发送到"window.location "。Href + path + '/config-loader.php'",您不妨将url参数设置为:
url: location.protocol + "//" + location.host + "/folder/jcart/config-loader.php",