1

This is my code. It works perfectly with Chrome but when I launch it Firefox it only works at the very first call. When I try to pass data for the second time I get this error:
"attempt to run compile-and-go script on a cleared scope".
I guess that the problem is in the function call in the "success" parameter, but I cannot understand what's wrong.
Thank you in advance for your help.

$.noConflict();
jQuery(document).ready(function(){
in_poll();
});  

function in_poll()
    {
    jQuery.ajax(
        {
        url: "prova.php",
        cache: false,
        dataType: "json",
        success: function(data)
            {
            .... OUTPUT DATA RETRIEVED....
            in_poll();
            },        
        error: function (xhr, ajaxOptions, thrownError) 
            {        
            alert(thrownError);
            setTimeout('in_poll()', 5000);//Try againg after 5 seconds
            },
        timeout: 25000
        });  
    }
Arnaldo
  • 817
  • 6
  • 8
  • This may be an issue with Firebug; can you try it with Firebug disabled and cache cleared? – Nic Feb 19 '12 at 08:08

2 Answers2

3

This is a FF specific error and most likely occurs because of cache, you may try to add a meta like this inside head tags

<meta http-equiv="cache-control" content="no-cache" />

For more see http://groups.google.com/group/mozilla.dev.platform/browse_thread/thread/10ff69b04b88e06f/87f89aaec17c1aed

The Alpha
  • 143,660
  • 29
  • 287
  • 307
  • You may also check this http://stackoverflow.com/questions/5433415/error-attempt-to-run-compile-and-go-script-on-a-cleared-scope – The Alpha Feb 19 '12 at 08:39
  • I have another problem on this script. I thought that it was caused by the previous one. After that it has retireved data from the php script it stops and doesn't make the following call. Do you have any suggestion? Thanks – Arnaldo Feb 19 '12 at 10:28
  • Please, forgive my bad English, I meant "next" and not "following". What I mean is to call the function "in_call()" after that the same function has retrieved data from the server. Just to have semething similar to a push technology. Thanks – Arnaldo Feb 19 '12 at 10:44
  • I'm not sure but you may try by adding this in your ajax call async:false. – The Alpha Feb 19 '12 at 10:53
  • Hi Heera I tried to click the arrow but the system says that I'm not allowed to do this, since I do not have enought reputation. As soon as I will be enabled, I will do it. Thanks – Arnaldo Feb 19 '12 at 21:39
  • You can click the tick beneath the arrow because you asked the question but thanks for your courtesy. – The Alpha Feb 19 '12 at 21:50
0

Finally I found the answer after a long headache. The tips given by Heera and Melee were helpful but didn't solve the problem at all. Practically my script was correct.
The problem was a "document.write()" inside the function into the parameter "success" (.... OUTPUT DATA RETRIEVED....) and which is not mentioned in the scritp I posted.
I don't know why but it seems that "document.write()" inside "success" works only with Chrome.

Arnaldo
  • 817
  • 6
  • 8