Jump to content

How to access a regular function inside jQuery


End User
 Share

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()?

Edited by End User
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 :)

Edited by MrFish
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...