I have written a little jQuery in order to be able to upload a picture with no page refresh, but when I upload the picture, I must refresh the page in oder for the new image to appear. I 开发者_如何学Pythonam sure it is something wrong with my jQuery script:
var uploader = new qq.FileUploaderBasic({
button: $('#account #picture .header')[0],
action: '<?= Route::url('Account Upload Avatar'); ?>',
allowedExtensions: ['png', 'jpg', 'gif'],
onSubmit: function()
{
},
onComplete: function(id, fileName, avatar)
{
$('#loader').hide();
$('#picture img').attr('src', avatar.url + '?' + (new Date).getTime());
}
});
});
I was going to edit the post to clean it up, but then I realized that you had an unmatched set of brackets; this would cause any browser that the javascript is loaded into to not execute it (whether or not you would be told of it is a different story).
The code should look like this:
var uploader = new qq.FileUploaderBasic({
button: $('#account #picture .header')[0],
action: '<?= Route::url('Account Upload Avatar'); ?>',
allowedExtensions: ['png', 'jpg', 'gif'],
onSubmit: function()
{
},
onComplete: function(id, fileName, avatar)
{
$('#loader').hide();
$('#picture img').attr('src', avatar.url + '?' + (new Date).getTime());
}
});
Note the });
left out at the end.
精彩评论