brgdotnet
asked on
How to check for the existence of a function before I call it. Trying to avoid the object not found error message.
I am using some JQuery functions that are accessible on the web. For example : ajax.aspnetcdn.com
My web application runs on an Intranet. However I am accessing the plugins that are located on the Internet.
Everything works great, however if the website becomes disconnected from the Internet, the JQuery functions at aspnetcdn.com will not be found. In that event an exception will be thrown in my call to the JQuery code, and I will get a "object not found" error message for the function being called. So using JQuery or Java Script how can I check if the function in not defined before attempting to call it?
My web application runs on an Intranet. However I am accessing the plugins that are located on the Internet.
Everything works great, however if the website becomes disconnected from the Internet, the JQuery functions at aspnetcdn.com will not be found. In that event an exception will be thrown in my call to the JQuery code, and I will get a "object not found" error message for the function being called. So using JQuery or Java Script how can I check if the function in not defined before attempting to call it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
if (typeof jQuery.foo == 'undefined') {
will work in this situation. Here is my specific code. below. The exception will be thrown at line 2 below. Can someone help me out some more so that I can prevent the JQuery is undefined message from being displayed.
<script src=”http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.js” type=”text/javascript”></s
<script src=”http://ajax.aspnetcdn.com/ajax/jquery.ui.js” type=”text/javascript”></s
<script src=”http://ajax.aspnetcdn.com/ajax/jjquery.ui/1.8.16/themes/humanity/jquery-ui.css.js” rel=”stylesheet” type=”text/css” />
1 <script type=”text/javascript”>
2 $(function() {
3 $(“[id$=myTetBox]”).datepi
4 changeMonth: true,
5 changeYear: true
6});
7});
</script>