Question : 'guid' is null or not an object in Jquery

I am running a layouts application page in sharepoint.  This page has a javascript function that uses the SPAPI based on an example from the SPAPI developer .  I keep getting the JavaScript error Line: 1569 Error: 'guid' is null or not an object.  The IE debugger shows the error is coming from line 1569 of jquery-1.4.1.js.  That line reads  "if ( !handler.guid ) " as the condition for "if ( !handler.guid ) { handler.guid = jQuery.guid++; }"  The only jquery function that I am aware of in my Javascript is "$('string')"  I will attach my JavaScript function in the code block.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
<script type="text/javascript" src="Scripts/SPAPI_Core.js"></script>
    <script type="text/javascript" src="Scripts/SPAPI_Lists.js"></script>
    <script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>
    <script type="text/javascript" src="Scripts/TADDScript.js"></script>
    <form id="form1" runat="server">
        
        <script type="text/javascript">
    <!--
        function getOptions(siteURL, element, selectedVal) {
            // sitteURL - url of the web, e.g., '/viewnet/railgun' 
            // element - jQuery object for the select list field. 
            // list - Name of the list to provide values 
            // selectedVal- (Optional) Value to select after select list has been rebuilt. If not supplied it defaults to 0 
            if (!selectedVal) { var selectedVal = ""; }
            // Clear existing <option> tags. 
            $("select[title='" + element + "']").empty();
            //alert('Here is element; ' + element);
            var durl = document.getElementById('<%=drop1Url.ClientID%>').value;
            var toturl = siteURL + durl +"/view";
            alert(toturl);
            //            return true;
            var sElement;
            if (selectedVal == "") {
                sElement = "<option value='0' selected='selected'>(none)</option>";
                //$(element).append("<option value='0' selected='selected'>(none)</option>");
            } else {
                sElement = "<option value='0' selected='selected'>(none)</option>";
                //$(element).append("<option value='0'>(none)</option>");
            }
            alert("sElement is " + sElement);
            // Get all OPTION values from list
            var lists = new SPAPI_Lists(toturl) 
            var listCollection = lists.getListCollection(); 
            if (listCollection.status == 200) 
            { 
                var optionData = new Array();
	            var items = listCollection.responseXML.getElementsByTagName('List'); 
                
	            alert('There are ' + items.length + ' lists in the site.');
	            for (var i = 0; i < items.length; i++) {
	                //alert(items[i].getAttribute('Title') + ' ' + items[i].getAttribute('ID'));
	                //optionData.push(items[i].getAttribute("Title") + ":"  + items[i].getAttribute("ID"));
	                sElement += "<option value='" + items[i].getAttribute('ID') + "'>" + items[i].getAttribute('Title') + "</option>";
	                //$("select[title='" + element + "']").append("<option value='" + items[i].getAttribute('ID') + "'>" + items[i].getAttribute('Title') + "</option>");
	            }
	            alert(sElement);
	            $("select#" + element).change($("select#" + element).html(sElement));
            
//                optionData.sort();
//	            for (var i=0; i < optionData.length; i++) 
//	            { 
//                
//	                 if (selectedVal == optionData[i].split(":")[0]) {
//                        $("select[title='" + element + "']").append("<option value='" + optionData[i].split(":")[1] + "' selected='selected'>" + optionData[i].split(":")[0] + "</option>");
//                    } else {
//                        $("select[title='" + element + "']").append("<option value='" + optionData[i].split(":")[1] + "'>" + optionData[i].split(":")[0] + "</option>");
//                    }
//	            } 
	             alert("status is :" + listCollection.statusText);
            } 
            else
            { 
              
	            alert('There was an error: ' + listCollection.statusText); 
                alert("status = " + listCollection.status);
            }

        }
        //-->
    </script>

Answer : 'guid' is null or not an object in Jquery

So what I had to do was insert the statement making the call to the jquery library into a try catch block and as my boss put it, "eat the exception".  This allows the Javascript function to proceed without causing a popup message showing the error.  (Maybe some more of these commercial sites should do this as I get tired of clicking no I don't want to debug.)   While I still can't explain why a supposedly mature technology like Jquery is supposed to be throws this error, I no longer have to suffer for it.
Random Solutions  
 
programming4us programming4us