2014-11-05 73 views
0

我想驗證&通過jquery驗證提交一個註冊表單。然而,當我做了電話後,我沒有得到服務器的響應我期待,但整個註冊頁面...JQuery驗證submitHandler返回頁面

Validateform.js

submitHandler: function(form) { 
    $.post("signupscript.php", $('#signup-form').serialize(), function(data){ 
    //data is the html of the signup page 
    }); 
} 

實際參數發送:

  • 背景:正確
  • 電子郵件:正確
  • 名:正確
  • 密碼:正確
  • password_confirm:正確

signupscript.php

include("connect.php"); 

mysqli_query($dbhandle, "INSERT INTO users (name, email, background, password) VALUES ('".$_POST['name']."', '".$_POST['email']."', '".$_POST['background']."', '".md5($_POST['password'])."')") or die(mysqli_error($dbhandle)); 

$userid = mysqli_insert_id($dbhandle); 
//Setting a cookie 

echo $userid; 

我認爲在我的代碼的某個地方,在註冊頁面被請求和答案早於預期答案返回。在使用驗證插件之前,一切都很順利。

回答

0

問題解決了。這是由於我沒有在問題中提到的外部因素造成的。我使用了一個URL來重寫「signup」,這個「signup.php」是註冊頁面。

RewriteRule ^ccre/signup ccre/signup.php [NC,L] 

因爲我沒有關閉要重寫的URL,所以它也適用於「signupscript.php」。我應該關閉這樣的網址:

RewriteRule ^ccre/signup$ ccre/signup.php [NC,L]