How come when I put everything in like this, it will not be working? <script type="text/javascript"> function disappear() { $("#response").fadeOut("slow") } $(document).ready(function() { $("#message_me").click(function() { $("#form").fadeIn("slow") }) $("#send").click(function() { var str = $("#input_form").serialize() $.post("send-mail.php",str,function(data) { $("#response").html(data).fadeTo("slow", 0.7) setTimeout("disappear()", 3000) }) }) $.get("counter.php", function(data) { $("#counter").html(data).fadeIn("slow") }) }) </script> I saved the above script in a separate file, let's say "myscript.js". Then I imported it in my html file like this <script src="myscript.js" type="text/javascript"></script>
Then, when I run this, it's not working. I've been trying to find the error. It says "missing } in XML expression at $("#send").... but then I switched places between $("#send")... and $.get(..., then the error comes out like "missing } XML expression at $.get(... instead. So I don't know what's wrong, Is there any function that needs to be put in between somehow? Again, now I delete everything except for $.get(.... in myscript.js. And I put them in the html file manually like <script type="text/javascript"> function disappear() { $("#response").fadeOut("slow") } $(document).ready(function() { $("#message_me").click(function() { $("#form").fadeIn("slow") }) $("#send").click(function() { var str = $("#input_form").serialize() $.post("send-mail.php",str,function(data) { $("#response").html(data).fadeTo("slow", 0.7) setTimeout("disappear()", 3000) }) }) }) </script> Now then, it works fine..... Can you tell me why it's not working in the uppermost one. cuz I want to put everything in one script file, and not to show any script in the html file. Thank you very much for any responses, really appreciate your time. DeaR