开发者

How to use .load function inside a .wrap function

I want to wrap content retrieved with load in jQuery, but I am not sure of the correct syntax, or possibly it's not possible to combine the two this way.

This is throwing an Uncaught TypeError:

$('video').wrap(function(){
        $.load('videohold开发者_StackOverflow社区er.php');
});


You need to execute the wrap in a callback (after the AJAX response comes back).

See: JQuery .load() callback function


No, that's not the correct syntax.

$('video').load('videoholder.php')


What Diodeus said. Try this:

$.load('videoholder.php', function(response, status, xhr) {
    $('video').wrap(response);
})


Use the callback in the load function and wrap the returned data.
Some rough code below.

$.load('videoholder.php', function( data ){ 
   $('video').wrap( data ); 
})

;

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜