I would like to learn how to achive the following with the other two functions, or at least the ajax function.
$('#myDiv').load('index.php #content');
How would I load #content in the index.php file, into #myDiv on the current page with the $.ajax and $.get methods?
The url param doesn't seem to take a selector with any other ajax method then load.
this doesn't work...
$.ajax({
url: 'index.php #content',
success: function(data) { 开发者_运维技巧
$('#myDiv').html(data);
},
});
Remove #content
from the URL and in the success
function, try this:
$( '#myDiv' ).html( $( data ).filter( '#content' ).html() );
It would be nice if we could do it your way, but.... Maybe the jQuery team can implement this in the next release.
精彩评论