0

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: "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. 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!!

1
  • Do you mean when you include the full url with http:// it does not work? Because this will be cause by browser security. You can not perform AJAX cross domain therefor you have to use a relative path such as /something, ./something or ../something. Commented Feb 2, 2011 at 11:35

4 Answers 4

2

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

Sign up to request clarification or add additional context in comments.

Comments

1

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

1 Comment

Thanks for your your help! The file located on the same server.When i use website/filename it works, but on a other computer it doesn't work and then i have to use /filename. So when i use http:// It works, but on a other computer it will work without http://. i can not use one if them. I like t know why that changes on different computers.
0

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

                }
                });
             }  

Comments

0

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.

2 Comments

Thanks for your your help! The file located on the same server.When i use website/filename it works, but on a other computer it doesn't work and then i have to use /filename. So when i use http:// It works, but on a other computer it will work without http://. i can not use one if them. I like t know why that changes on different computers.
Are the computers running different operating systems or browsers?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.