URL的Javascript绝对路径在一个页面上有效,但在另一页面上创建ajax错误消息 [英] Javascript absolute path to URL works on one page, but creates ajax error message on another

查看:54
本文介绍了URL的Javascript绝对路径在一个页面上有效,但在另一页面上创建ajax错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个网址:

http://s140452.gridserver.com/view-pullsheet/

https://s140452.gridserver.com/locations/

当浏览位置页面上的任何属性(以及任何单个属性,使用侧边栏过滤属性,从抽签"中添加和删除属性)时,jcart.js脚本可以正常工作-它可以控制在活页纸"中添加和删除照片.

When browsing through any properties on the locations page (as well as any single property, filtering properties using the sidebar, adding and removing properties from the "pullsheet") the jcart.js script works fine -- it is in control of adding and removing photos from the "pullsheet".

但是,在此页面上, http://s140452.gridserver.com/view-pullsheet/,出现以下错误"Ajax错误:编辑jcart.js中的路径以进行修复".

From this page however, http://s140452.gridserver.com/view-pullsheet/ , I get the following error "Ajax error: Edit the path in jcart.js to fix".

有问题的代码是:

    var path = 'https://s140452.gridserver.com/wp-content/themes/re/assets/functions/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;
    }());

该脚本如何在位置"页面上正常运行,但是从其他URL引发错误?我该如何解决?

How can the script be working fine on the locations page but throw an error from a different URL? How can I fix this?

谢谢!

jcart.js位于@ https://s140452.gridserver.com/wp-content/themes/re/assets/js/jcart.js

jcart.js is located @ https://s140452.gridserver.com/wp-content/themes/re/assets/js/jcart.js

推荐答案

,因为您遇到了相同的起源问题. https与http

because you are running into the same origin problem. https vs http

var path = 'https://s140452.gridserver.com/wp-content/themes/re/assets/functions/jcart',

var path = '//s140452.gridserver.com/wp-content/themes/re/assets/functions/jcart',

这篇关于URL的Javascript绝对路径在一个页面上有效,但在另一页面上创建ajax错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆