Jump to content

How to access a regular function inside jQuery


End User

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...