Cannot get Jquery .ajax or .load to execute scripts -
here's test.html :
<html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script> </head> <body> <script language=javascript> $(document).ready(function() { $("button").click( function() { $.ajax({ url : "http://localhost:101/test2.html", datatype : "html", success: function(data){ alert(data); $("div").html(data); } }); }); }); /* $(document).ready(function() { $.ajax({ url : "http://localhost:101/scripts/testscript.js", datatype : "script" //success: function(data){ $("#inner-main").html(data); } }); }); */ </script> <button> bleh </button> <div> </div> </body> </html>
here's test2.html :
<script type=javascript> alert("lock , load, outside!"); $(document).ready(function () { alert("lock , load!"); }); </script> <p>hello, world </p>
i cannot test1 load test2 , execute scripts in it. < p > (hello world) display in div. scripts though, not execute. alert see function called on success.
what doing wrong ?
the url test1.html http://localhost:101/test1.html
in both scripts, change
<script language=javascript>
, <script type=javascript>
to
<script type="text/javascript">
it work.
before learning , using ajax, recommend learn valid html first. not valid html why jquery or browser compile correctly?
Comments
Post a Comment