douna1941
2013-03-02 02:28 阅读 45

使用jQuery AJAX获取语法错误[关闭]

I am new to jQuery and am trying to copy an example from a website I found that uses AJAX I need to take the PHP variable and pass it to another PHP page without refreshing the entire page. I have come up with the following code below but I am getting a syntax error

Uncaught SyntaxError: Unexpected token )

Here is my code:

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

My PHP page:

<!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>

I am also getting the following errors but I think they may be related to the syntax error:

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条回答 默认 最新

  • 已采纳
    douhui8025 douhui8025 2013-03-02 02:40

    Your closing tags:

     )};
    

    should be this way:

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

    and script order will be this way and mind the closing </$:

    <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>
    

    点赞 评论 复制链接分享
  • douzhi1937 douzhi1937 2013-03-02 02:33
     $.post("script.php",
         {textBox: textBox},
         function(data,status){}
       );
    

    Also read : http://api.jquery.com/jQuery.post/

    点赞 评论 复制链接分享

相关推荐