vendredi 14 novembre 2014

Issue on Registering JavasCript Files


Vote count:

0




I have two very simple files : email.js and script.js


the email.js is



$(function () {
function txtInput(elem) {
var inputData = $.trim(elem.val());
if (inputData == "") {
alert("Filed Is Empty");
}
else{
return inputData;
}
}
});


and the script.js



$(function () {
var proceed = false;
$("#btnContactUs").on("click", function (e) {
if (txtInput($('#name'))){
proceed = true;
}else{ proceed = false }
e.preventDefault();
});
});


which I registered them in index.php as



<script src="js/email.js"></script>
<script src="js/script.js"></script>


Issues:


1 - First of all the $("#btnContactUs").on("click", function (e) {}); is not doing any thing so I removed the



$(function () {

});


from the email.js and it started working! Can you please let me know why the $(function () {}); is doing this?


2 - Now the Code is functioning(after removing the $(function () ... from email.js) BUT I am getting a warning/error in the console as:


enter image description here


Can you please let me know why this is happening? and how can I fix it?


Thanks,



asked 1 min ago

Suffii

679






Issue on Registering JavasCript Files

Aucun commentaire:

Enregistrer un commentaire