jQuery eval of ajax inline script not throwing errors

Posted by Josh on Stack Overflow See other posts from Stack Overflow or by Josh
Published on 2010-03-29T03:23:34Z Indexed on 2010/03/29 5:33 UTC
Read the original article Hit count: 423

Filed under:
|
|
|
|

http://stackoverflow.com/questions/606794/debugging-ajax-code-with-firebug

This question is quite similar, though old and without real answers.

I'm currently putting together an app that has scripts that get loaded in with an ajax request.

An example:

var main = _main.get();
main.load( someurl );

Where someurl is a page that contains an inline script element:

<script type="text/javascript"> 
$(document).ready( function(){
    var activities = new activities();
    activities.init();
});
</script>

jQuery will do a line by line eval of js that lives in inline script tags. The problem is, I get no errors or any information whatsoever in firebug when something goes awry.

Does anyone have a good solution for this? Or a better practice for loading pages which contain javascript functionality?

Edit: A little progress... so at the top of the page that is being loaded in via ajax, I have another script that was being included like this:

<script type="text/javascript" src="javascript/pages/activities.js"></script>

When I moved the inline $(document).ready() code in the page to the end of this included file, instead, syntax errors were now properly getting thrown.

As an aside, I threw a console.log() into the inline script tag, and it was being logged just fine. I also tried removing the $(document).ready() altogether, and also switching it out for a $(window).load() event. No difference. May have something to do with the inline scripts dependency on the included activities.js, I guess.

:: shakes head :: javascript can be a nightmare.

© Stack Overflow or respective owner

Related posts about php

Related posts about AJAX