Solved

jQuery doesn't fire at all. Nothing happens!

Posted on 2013-06-04
15
353 Views
Last Modified: 2013-06-05
Hi experts,

I have strange issue with jquery on my coldfusion page.

Issue my jquery doesn't work at all, i mean it doesn't even call a function neither it shows any error. Nothing happends absolutely!!  I do have the jquery library included on the page. I have no idea what happens there and why. I have worked with jquery on other applications thought I am no expert.

Would you help me figure it out...

Thanks,
samssAabee
0
Comment
Question by:samssAabee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
15 Comments
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 39219841
...can you post the code that's not working?  How do you know it's not firing?  Maybe it's firing, but not working the way you expect...
0
 

Author Comment

by:samssAabee
ID: 39219887
Well that's what I thought, then I just added a simple function which does nothing but just an alert and called the function. And that's when I thought it's not firing at all.  So here is the code I used for testing.

Also if i use pure javascript like using getElementById('forTest').value() it works fine.

<form>
<input type="text" name="forTest" id="forTest" value="I have some text" onmousemove="testSomething();" />
<input type="button" value="Test Function" onclick="testSomething();" />
</form>


<script src="jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>

<script type="text/javascript">
  function testSomething()
  {      
       var getText  = $('#forTest').val();
       alert(getText);      
  }

</script>
0
 
LVL 12

Expert Comment

by:zappafan2k2
ID: 39219956
If what you showed above is how the code is written on the page, try putting the function above the HTML that calls it.  In the above scenario, when the button is created, the function doesn't exist.
0
Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

 
LVL 34

Accepted Solution

by:
Paul MacDonald earned 500 total points
ID: 39220024
Your reference to the jQuery library is bad.  I don't know where you keep your copy (or if you even have one, but it's not where your page is running from.

Try this:

<html>

<form>
<input type="text" name="forTest" id="forTest" value="I have some text" onmousemove="testSomething();" />
<input type="button" value="Test Function" onclick="testSomething();" />
</form>


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
 </script>

<script type="text/javascript">
  function testSomething() 
  {   
       var getText = $("#forTest").val();
       alert(getText);      
  }

</script> 


<html>

Open in new window

0
 

Author Comment

by:samssAabee
ID: 39220164
Sorry, I forgot to change that link. The reference I use is this.

<script src="scripts/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
0
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 39220187
Nevertheless, that's what's wrong.  

Maybe the tag needs to read...
   <script src="/scripts/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
...or...
   <script src="~/scripts/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
...or something else beyond my ken.  It looks like a path issue.
0
 

Author Comment

by:samssAabee
ID: 39220215
I tried these...

 <script src="/scripts/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
and

 <script src="scripts/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>

and even moved the script to the same directory where my code file is and used this..

 <script src="jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>

didn't work.

But havent' tried this...

 <script src="~/scripts/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
0
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 39220261
Is it possible you have javascript turned off in your browser?  Did the example I posted work for you?  If so, javascript (and therefore jQuery) is fine, but your browser can't find the .js library.
0
 

Author Comment

by:samssAabee
ID: 39220350
I will verify the javascript settings in my browser. I know javascript works on this same page.
0
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 39220772
Maybe try a different browser?  

Again, my version of your page worked for me - does it work for you?
0
 

Author Comment

by:samssAabee
ID: 39222935
I turned on the script debbugger to see what's going on. So now it complains that the object is not defined referring to the .val() function. So obviously it doesn't find my jquery reference.

So like you were suggesting, i tried all the possible paths to this jquery file but it doen't still get it. It's definitely my local problem though it doesn't make sense to me.
0
 

Author Comment

by:samssAabee
ID: 39223000
I just tried your jquery reference. https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js 

That works!! so I think the jquery file is probably corrupted. I am trying to down load this 1.6.2 version, because I don't want to hard code the absolute URL on my reference.
0
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 39223041
Great.  Let us know if/when it's working properly.
0
 

Author Comment

by:samssAabee
ID: 39223080
Sweet! downloaded it from the same site (https://ajax.googleapis.com) and saved it to my scripts folder and referenced it on my code. It works!!!

Good job!! thanks very much! I am back in business!
0
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 39223097
Happy to help.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
size of file 1 37
Powershell PGP and SFTP 1 48
powershell script to get user from Active directory an add them to a group 14 55
run powershell script endlessly 3 31
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question