I am getting an error on a page that has a shopping cart script in it.
Error: ‘Ajax error: Edit the path in jcart.js to fix.’
The issue, as far as I can tell, is around relative paths from files. I’ve tried all sorts of variations to getting the path correct to no avail.
The error is specific to a file path location variable in a JavaScript file called jcart.js. The location of the files are as follows:
Files/Directories:
- 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’,
Since the actual ajax request would be made to “window.location.href + path + ‘/config-loader.php'”, you might as well set your url parameter as:
url: location.protocol + “//” + location.host + “/folder/jcart/config-loader.php”,
Filed under: error, programming, tips | Tagged: Ajax error: Edit the path in jcart.js to fix |
Aku tidak mengerti tentang bahasanya.saya ingin sekali