这可能吗?

时间:2009-08-19 16:55:12

标签: php jquery uploadify

我有一个问题,我正在使用uploadify,每次文件完成上传时,脚本都会运行一个位于 onComplete 语句中的代码,来自onComplete语句的代码,它是对页面的ajax调用,我们称之为X,我怎么知道脚本第一次访问页面X的时间?

2 个答案:

答案 0 :(得分:1)

虽然我不熟悉uploadify,但如果你在全局范围内设置变量(在o​​nComplete之外),我会称之为var hasBeenCalled,在页面加载时将其设置为false。 调用onComplete时,请执行:

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

希望有所帮助

答案 1 :(得分:0)

试试这个:

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,
  ...
});
相关问题