Solved

Running two javascripts on one page

Posted on 2015-01-18
10
163 Views
Last Modified: 2015-01-19
Having these two scripts on the very same page, only the latter one is run.

<script>
$().ready(function() {
      // validate signup form on keyup and submit
      $("#signupForm").validate({
            rules: {
                ...
            }
      });
});
</script>

and

      <script>
      $(function() {
            $('#lennart').avgrund({
                  ...
            });
      });
      </script>

What should be added to get both working?
0
Comment
Question by:lericson
  • 4
  • 3
  • 3
10 Comments
 
LVL 6

Expert Comment

by:rjohnsonjr
ID: 40556232
Should the first one be :

$(document).ready(function() {
0
 

Author Comment

by:lericson
ID: 40556246
In the script, it is stated as I wrote it. Let me state it: I am a complete and utterly newbie.
0
 
LVL 6

Accepted Solution

by:
rjohnsonjr earned 250 total points
ID: 40556266
ok,  http://api.jquery.com/ready/  shows the syntax is correct
0
 

Author Comment

by:lericson
ID: 40556277
Sorry, don't understand your statement. Would you be kind enough to explain a nit more.
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 40556282
What rjohnsonjr is saying is your first script should be changed from

$().ready(function() {

To

$(document).ready(function() {
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:lericson
ID: 40556312
Rob Jurd, thanks for explaining!
rjohnsonjr, Even though it is changed according to the suggestion, it doesn't work.
All experts, Any other suggestion?
0
 
LVL 6

Expert Comment

by:rjohnsonjr
ID: 40556407
I meant to say that the page I posted shows that the syntax you provided is correct also.

I would install chrome browser and use chrome developer tools to see what the javascript errors are.

https://developer.chrome.com/devtools
0
 
LVL 42

Assisted Solution

by:Rob Jurd, EE MVE
Rob Jurd, EE MVE earned 250 total points
ID: 40556648
Are you sure the first is not running? What happens if you add an alert()

I.e.

$(document).ready(function() {
    alert("dom is ready");
    // .... rest of your code below
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 40556650
And certainly get familiar with any of the browsers dev tools as @rjohnsonjr has suggested
0
 

Author Comment

by:lericson
ID: 40557542
My problem turned out to be a conflict between the jquery scripts versions I used. When I downloaded the latest version of jquery and installed it and referred to it, the problem was gone.

I hadn't given information in my question about which jquery versions (I actually had two) I was using, so you had no chance to spot the real problem.

Thanks for your efforts.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now