I got this error in Firefox only, everything works perfectly well in IE and Chrome, I’m using Firefox v 15.0. Here’s my code
<script type="text/javascript" src="/_layouts/Scripts/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(function () {
// some code here
});
Exception occurs on first line ( document ready ), it seems that page can’t reference jQuery library at all, but if I click on source link from error console, I can see in browser jQuery library’s code. This is weird, because I have no error in IE or Chrome.
Any ideas why this is happening ?
EDIT:
Here’s whole js code
$(function () {
var digitCode;
$('input[type=submit][id*=btnCancel]').on('click', function (e) {
e.preventDefault();
closeModalDialog('Cancel');
});
$("select[id*=ddlContacts]").on('change', function () {
var contactID = $(this).val();
if (parseInt(contactID) == 0) {
$('span[id*=lblCEOTitle]').text("");
return;
}
var data = { contactId: contactID };
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "AddCompany.aspx/CeoTitle",
data: JSON.stringify(data),
dataType: "json",
success: function (result) {
$('span[id*=lblCEOTitle]').text(result.d);
$('input[type=hidden][id*=hdnFieldCeoTitle]').val(result.d);
},
error: function () {
alert('error');
}
});
});
});
Unless you work offline, you should let a CDN host these files for your users. Doing so has several advantages over hosting jQuery on your server(s): decreased latency, increased parallelism, and better caching. For more details check out this article : http://encosia.com/3-reasons-why-you-should-let-google-host-jquery-for-you/
This also saves some trouble (pathfile management, corrupt files, bad versions etc.) one of which you have just encountered now.