Solved

Running two javascripts on one page

Posted on 2015-01-18
10
170 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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
 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Performance for Office 365 6 46
execute script based on HTML event 7 23
simple javascript form validation 2 17
Call a function within the ASP code 4 9
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…
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 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…

786 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