简体   繁体   English

AJAX jQuery URL不起作用

[英]AJAX Jquery url not working

I have a strange problem with Jquery Ajax with the following code. 我对带有以下代码的Jquery Ajax有一个奇怪的问题。

Situation 1: 情况一:

function leuk(decrease_id, user_id) {
    $.ajax({
        type: "POST",
        url: 'http://schoolprove.nl/nieuw/index.php/leerlingen/checkvoortgang/',
        data: 'decrease_id=' + decrease_id + '&user_id=' + user_id,
        success: function (msg) {
            $('#output').html(msg);

        }
    });
}

Situation 2 情况二

function leuk(decrease_id, user_id) {
    $.ajax({
        type: "POST",
        url: '/nieuw/index.php/leerlingen/checkvoortgang/',
        data: 'decrease_id=' + decrease_id + '&user_id=' + user_id,
        success: function (msg) {
            $('#output').html(msg);

        }
    });
}

The AJAX url works sometimes whith http:// and sometimes without. AJAX网址有时可以使用http://,有时可以不使用。 I build and error catch when a error occured. 发生错误时,我进行构建并捕获错误。 This works very well at IE but Firefox doesn't give a error. 这在IE上效果很好,但是Firefox不会出现错误。 So at some computers with Firefox this will not work. 因此,在某些使用Firefox的计算机上,此功能将无效。 It is very strange and i don't know why it will not work. 这很奇怪,我不知道为什么它不起作用。

Situation 1: Works sometimes 情况1:有时有效

Situation 2: Works sometimes 情况2:有时有效

Sometimes situation 1 works and ad a other computer situation 2 works, WHY? 有时情况1起作用而另一台计算机情况2起作用,为什么? Anybody know how to solve? 有人知道如何解决吗?

Thank you very much!! 非常感谢你!!

Redirect your domain like this tonerize.com to www.tonerize.com will solve this issue 将您的网域重定向到www.tonerize.com这样的墨粉化网站即可解决此问题

please read this http://en.wikipedia.org/wiki/Same_origin_policy . 请阅读此http://en.wikipedia.org/wiki/Same_origin_policy for more information 欲获得更多信息

Is your ajax file located on some other server? 您的ajax文件位于其他服务器上吗?

If no then, you need not specify the the whole path for url. 如果不是,则无需指定url的整个路径。 Its enough if you use 如果使用就足够了

url: 'ajaxfilename.php' //depending on the folder the file is located url:'ajaxfilename.php'//取决于文件所在的文件夹

You can not use a path such as this for AJAX. 您不能将这样的路径用于AJAX。

http://something.com/file.php

It has to be relative to your file and located on your server like to. 它必须相对于您的文件,并且必须位于您的服务器上。

/file.php

I am not quite sure what your problem is though, your question does not provide any error information. 我不太确定您的问题是什么,您的问题没有提供任何错误信息。

I found the solutions it is causing due to cache, try to disable the cache and add the random value in your query string. 我发现了由于缓存导致的解决方案,请尝试禁用缓存并在查询字符串中添加随机值。

function leuk(decrease_id,user_id)
              {     
                $.ajax({
                    type: "POST",
                    cache:fale,
                    timeout:10000,
                    url: '/nieuw/index.php/leerlingen/checkvoortgang/?rnd='+Math.random(),

                    data: 'decrease_id='+decrease_id+'&user_id='+user_id,
                    success: function(msg){
                        $('#output').html(msg);

                }
                });
             }  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM