调用自定义函数时的ReferenceError

时间:2015-08-04 07:29:06

标签: javascript

  1. 我有一个按下按钮时调用的功能。    function account_verify() {var user = $(“#user”)。val();
    var pwd = $(“#pwd”)。val(); VAR REQ = '用户=' +用户+ '&安培; PWD =' + PWD + '&安培; wlanusermac =' + wlanusermac + '&安培; wlanuserip =' + wlanuserip + '&安培; wlanbssid =' + wlanbssid + '&安培; wlanssid =' + wlanssid +” &安培; wlanapmac ='+ wlanapmac; $就({         键入:“POST”,dataType:“text”,data:req,processData:false,url:“account_verify.php”,成功:
    account_verify_success,error:account_verify_fail}); }
                                    用户名:                                                          密码:                                                                          

                <input type="button" id="lLogin" value="login" onClick="account_verify()">
                <input type="button" id="lClear" value="Cancel" onClick="document.getElementById('user').value = document.getElementById('pwd').value = '';"><br>
                </td>
                <td></td>           </tr>   </table>     </body> </html>
    

    未捕获的ReferenceError:未定义account_verify          我错过了什么?

1 个答案:

答案 0 :(得分:0)

更改此

<script type="text/javascript">
    function account_verify() {
        var user = $("#user").val();
        var pwd = $("#pwd").val();
        var req = 'user=' + user + '&pwd=' + pwd + '&wlanusermac=' + wlanusermac + '&wlanuserip=' + wlanuserip + '&wlanbssid=' + wlanbssid + '&wlanssid=' + wlanssid + '&wlanapmac=' + wlanapmac;
        $.ajax({
            type: 'POST',
            dataType: 'json',
            data: req,
            url: 'account_verify.php',
            success:function(data)
            {

            }
            error:function(data)
            {

            }
        });
    }
</script>