What is the error in this jQuery code?
I have the below jQuery code, but it does not work at all.
Firebug says there is a )
missing, but where?
$.get(url: 'example.html', function(data) {
var $page = $(data);
$page.filter('script').add($page.find('script')).each(function(){
$.globalEval(this.text || this.textContent || this.innerHTML || '');
});
$('#form').html(data);
}
});
$.get(url: 'example.html',...
should be
$.get('example.html',...
and you have one }
too much at the end.
$.get('example.html', function(data) {
var $page = $(data);
$page.filter('script').add($page.find('script')).each(function(){
$.globalEval(this.text || this.textContent || this.innerHTML || '');
});
$('#form').html(data);
} // <---- this thing is not needed
});
You had a extra }
and url: 'example.html'
that part should not contain url:
$.get(/*url: This part is removed*/'example.html', function(data) {
var $page = $(data);
$page.filter('script').add($page.find('script')).each(function(){
$.globalEval(this.text || this.textContent || this.innerHTML || '');
});
$('#form').html(data);
//} This one has also been removed
});
精彩评论