views:

147

answers:

2

I have a question, I'm using uploadify, and every time when a file finishes to upload, the script runs a code which is located in the onComplete statement, and the code from the onComplete statement it's an ajax call to a page, let's call it X , how can I know when the script access the page X for the first time?

+1  A: 

Although I'm not familiar with uploadify, if you set a variable in the global scope (outside the onComplete), I'll call it var hasBeenCalled, set it to false at the page load. When onComplete is called, do:

if (hasBeenCalled)
{
// not the first time
}
else
{
//first time
hasBeenCalled = true;
}

Hope it helps

Ryan
doesn't work.. :(
Uffo
A: 

try with this:

var myFirstEvent = false;
var myFunOnComplete = function()
{
    if (!myFirstEvent)
    {
       // code for fist instance
    }

    // set finish the first instance
    myFirstEvent = true;

    // code for ajax call
    callAjax();

}


jQuery('#fInput').uploadify({
  ...
  'onComplete': myFunOnComplete,
  ...
});
andres descalzo
I have already solve it! thx anyways
Uffo