使用jQuery AJAX获取语法错误


Using jQuery AJAX getting syntax error

我是jQuery的新手,正在尝试从我发现的使用AJAX的网站上复制一个示例。我需要获取PHP变量并将其传递到另一个PHP页面,而不刷新整个页面。我已经想出了下面的代码,但我得到了一个语法错误

Uncaught SyntaxError: Unexpected token )

这是我的代码:

$("Button").click(function(){
    var textBox = $("textBox").val();
$.post("script.php",
    {textBox: textBox},
     function(data,status)
    )};
)};

我的PHP页面:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  <head>
    <script type='text/javascript' src='script.js'></script>
    <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'></$
    <title>LCD Display</title>
  </head>
  <body>
        <form id="lcd" action="script.php" method="post">
     <input name='textBox' type='text' />
     <input type='submit' id= 'Button' value='Press to see something cool'/>
     </form>
    <div id='ResponseDiv'>
    </div>
    <iframe id="video" src="http://192.168.0.11:8081" height="120" width="160"></iframe>
  </body>
</html>

我也得到了以下错误,但我认为它们可能与语法错误有关:

Resource interpreted as Document but transferred with MIME type multipart/x-mixed-replace: "http://192.168.0.11:8081/".
Resource interpreted as Document but transferred with MIME type image/jpeg: "http://192.168.0.11:8081/".

您的结束标签:

 )};

应该是这样的:

$("Button").click(function(){
var textBox = $("textBox").val();
$.post("script.php",
    {textBox: textBox},
      function(data,status){
   });
});

脚本顺序是这样的,注意关闭</$:

<head>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'>
</script>
<script type='text/javascript' src='script.js'></script>
<title>LCD Display</title>

 $.post("script.php",
     {textBox: textBox},
     function(data,status){}
   );

另请阅读:http://api.jquery.com/jQuery.post/