开发者

How to pass a value to an ajaxUpload function?

This is my Html code and I'm trying to pass my id(test1) to fileUp function. It only works when I type 'test1' and stops working when I'm trying to pass a variable. Please let me know if there is a way to overcome this problem.

开发者_Go百科<a id='test1' href="#" onclick="fileUp(1, 'test1')">Upload Your file</a>

function fileUp(id,nameTest){
    var test=nameTest;

    new AjaxUpload(nameTest , {
        action: 'upload-test.php',
        onComplete: function(file, response){                        
            alert(response);
        }
    });
};


What do you mean "it doesn't work"?

<a id='test1' href="#" onclick="fileUp(1, this.id)">Upload Your file</a>

In jQuery:

$('#test1').bind('click', function (evt) {
    fileUp(1, $(this).attr('id'));

    evt.preventDefault();
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜