Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Running two javascripts on one page

Posted on 2015-01-18
10
Medium Priority
?
208 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
[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
  • 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 1000 total points
ID: 40556266
ok,  http://api.jquery.com/ready/  shows the syntax is correct
0
Understanding Linux Permissions

Linux for beginners: How to view the permissions associated with files and directories and also how you can change them.

 

Author Comment

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

Expert Comment

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

$().ready(function() {

To

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

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 43

Assisted Solution

by:Rob
Rob earned 1000 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 43

Expert Comment

by:Rob
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

Not sure which OpenStack Certification to get?

So you’ve realized you might want to get certified in OpenStack, but you’re not sure what the benefits might be or even which one you should take. You know there are several certification courses you can choose from, but how do you know which one is right for you?

Question has a verified solution.

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

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn how to dynamically set the form action using jQuery.
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…
Suggested Courses

721 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