godsent Posted May 17, 2009 Share Posted May 17, 2009 I just started learning JavaScript and jQuery. For example here is how my form looks like so far. <input name="field1" type="text" id="field1"> <input name="field2" type="text" id="field2"> <input type="submit" name="Submit" value="Submit" class="attack"> And this is how my code looks: <script type="text/javascript"> $(document).ready(function(){ $(".attack").click(function(){ var one = "this is one"; var two = "this is two"; $.post("test.php", { var1: "one, var2: two }, function(data){ alert("Data Loaded: " + data); }); }); }); </script> What I'm trying to do is get variables "one" and "two" directly from the text fields. Please help me if you know how. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 17, 2009 Share Posted May 17, 2009 You're messing up the quotes. See here: { var1: "one, var2: two } You have a quote opened before "one", but you never closed it. It should look like this - { var1: "one", var2: "two" } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.