Forum Moderators: open

Message Too Old, No Replies

Javascript errors

         

toplisek

2:40 pm on May 10, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have tested website and has some javascript errors.
There is in example error like:

1. Jquery is not defined.
Does it mean jquery javascript file is not with correct path (link) to be used if application call it?

2. $("#Mysearchforms1").validate is not a function

What can I do when I receive such error notice. Can be this corrupted syntax of a programming language or some callled function can not be performed as code calls wrong function which is not there?

I have noticed that input has just one field. Is this issue as AJAX validation will check also field which is not there?
In one eaxmple I have more fields. Should be all fields there to overcome such error?


like:
<script type="text/javascript">
$(document).ready(function() {
$("#SearchForm").validate({

rules: {
query: {
required: true
},
myemail: {
required: true,
email: true
}
},
messages: {
query: {
required: "Please enter your name"
},
mymail: {
email: "Email is not validated"
}
}
});
});
</script>

rocknbil

5:06 pm on May 10, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You probably have your script calling jQuery **before** this code or an invalid path to your jQuery library.

<script type="text/javascript" src="/path/to/your/jQuery.js"></script>
<script type="text/javascript" src="/path/to/your/functions.js"></script>

Another approach, wherever you have these functions, wrap it in a conditional:

if (jQuery) {
// OK, we can use the library
}

or

if ($) {
// OK, we can use the library
}

or

if (typeof jQuery != 'undefined') {
// OK, we can use the library
}

toplisek

7:37 am on May 11, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have put as you posted but should be this inside javascript element?
if (jQuery) {
jQuery(document).ready( function () {
var oTable = $('#example').dataTable( {
"sDom": 'RC<"clear">lfrtip'
} );
new FixedHeader( oTable );
} );
}

or

if ($) {
$(document).ready( function () {
var oTable = $('#example').dataTable( {
"sDom": 'RC<"clear">lfrtip'
} );
new FixedHeader( oTable );
} );
}

toplisek

9:30 am on May 11, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have solved issue. It was issue that one added plugin blocked all other with error.

But I have still one issue as DataTable code (datatables) does not work.
What can be issue if local works but server side does nto work:
<script language="JavaScript" charset="utf-8" type="text/javascript">
/*<![CDATA[*/
jQuery(document).ready( function () {
var oTable = $('#example').dataTable( {
"sDom": 'RC<"clear">lfrtip'
} );
new FixedHeader( oTable );
} );
/*]]>*/
</script>

URL: [datatables.net...]
In original version is $ inside jQuery(document).ready( function () {

But my inspector checking reports an error when I use original source code and table is still not shown.