Solved

Running two javascripts on one page

Posted on 2015-01-18
10
193 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 250 total points
ID: 40556266
ok,  http://api.jquery.com/ready/  shows the syntax is correct
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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 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 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
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 …
The viewer will learn how to dynamically set the form action using jQuery.
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)
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

631 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