2013-03-02 152 views
0

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

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/". 

回答

2

你关闭标签:

)}; 

应该是这样的:

$("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>