DiegoP.
DiegoP.

Reputation: 45737

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);
    }
});

Upvotes: 0

Views: 84

Answers (3)

albertein
albertein

Reputation: 27120

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
});

Upvotes: 0

Pavel Morshenyuk
Pavel Morshenyuk

Reputation: 11471

$.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
});

Upvotes: 0

Felix Kling
Felix Kling

Reputation: 816364

$.get(url: 'example.html',...

should be

$.get('example.html',...

and you have one } too much at the end.

Upvotes: 2

Related Questions