开发者

AJAX Jquery url not working

I have a strange problem with Jquery Ajax with the following code.

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: "P开发者_C百科OST",
        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. I build and error catch when a error occured. This works very well at IE but Firefox doesn't give a error. So at some computers with Firefox this will not work. It is very strange and i don't know why it will not work.

Situation 1: Works sometimes

Situation 2: Works sometimes

Sometimes situation 1 works and ad a other computer situation 2 works, WHY? Anybody know how to solve?

Thank you very much!!


Redirect your domain like this tonerize.com to www.tonerize.com will solve this issue

please read this http://en.wikipedia.org/wiki/Same_origin_policy. for more information


Is your ajax file located on some other server?

If no then, you need not specify the the whole path for url. Its enough if you use

url: 'ajaxfilename.php' //depending on the folder the file is located


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);

                }
                });
             }  


You can not use a path such as this for 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜