End User Posted August 27, 2010 Share Posted August 27, 2010 I've got a regular javascript function inside my doc.ready() block that I'd like to call from code that's returned via an AJAX call: $(document).ready(function(){...blah blah blah... function someFunction(str){ ...code code code... return str; }}); // end of doc.ready() A regular call to someFunction(str) doesn't work unless I place the function outside of the doc.ready() block. I'd like to place it inside the doc.ready() block if at all possible. How do I call this function when it's inside doc.ready()? Link to comment Share on other sites More sharing options...
MrFish Posted August 27, 2010 Share Posted August 27, 2010 To get by this you can easily put this function inside the window object. I often do it myself. $(document).ready(function(){...blah blah blah... window.someFunction = function(str){ ...code code code... return str; }}); // end of doc.ready() Now it should work.Edit:lol, justsomeguy Link to comment Share on other sites More sharing options...
justsomeguy Posted August 27, 2010 Share Posted August 27, 2010 window.someFunction = function() ...jinx! Link to comment Share on other sites More sharing options...
End User Posted August 27, 2010 Author Share Posted August 27, 2010 Thank you, JSM and MrFish. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.