javascript - Including Jquery Library from a external scource -


i trying include following jquery library:

http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js

when run bellow code alert not displayed:

<div style="float: left; margin-left:0px; width:20px; padding-top: 10px;">     <form id="payment_form" action="https://arembepe.net/tester3.php" method="post">         número cartão: <input type="text" id="card_number"/>         <br/>     </form> </div>  <script src="https://assets.pagar.me/js/pagarme.min.js"></script><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"> alert(123); </script> 

however when run same code without reference jquery library alert displayed:

<div style="float: left; margin-left:0px; width:20px; padding-top: 10px;">     <form id="payment_form" action="https://arembepe.net/tester3.php" method="post">         número cartão: <input type="text" id="card_number"/>         <br/>     </form> </div>  <script src="https://assets.pagar.me/js/pagarme.min.js"></script><script> alert(123); </script> 

after reading comments change code to:

    <div style="float: left; margin-left:0px; width:20px; padding-top: 10px;">         <form id="payment_form" action="https://arembepe.net/tester3.php" method="post">             número cartão: <input type="text" id="card_number"/>             <br/>                 </form>     </div>      <script src="https://assets.pagar.me/js/pagarme.min.js"></script>     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>     <script>                 alert($("#card_holder_name").val());     </script> 

with new code manage make alert(123) display. when try use alert($("#card_holder_name").val()); "referenceerror: $ not defined" can't use jquery function.

if put script source tag run script @ source, need add third script tag. code:

<div style="float: left; margin-left:0px; width:20px; padding-top: 10px;">     <form id="payment_form" action="https://arembepe.net/tester3.php" method="post">         número cartão: <input type="text" id="card_number"/>         <br/>     </form> </div>  <script src="https://assets.pagar.me/js/pagarme.min.js"></script><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"> alert(123); </script> 

should become instead:

<div style="float: left; margin-left:0px; width:20px; padding-top: 10px;">     <form id="payment_form" action="https://arembepe.net/tester3.php" method="post">         número cartão: <input type="text" id="card_number"/>         <br/>     </form> </div>  <script src="https://assets.pagar.me/js/pagarme.min.js"></script><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script> alert(123); </script> 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -