2012-10-09 42 views
1
<form enctype="multipart/form-data" method="post" name="settingsForm" id="settingsForm"> 
     Admin Name: <input type="text" value="Vipul Sharma" name="admin[admin_name]" id="admin_name"><br> 
     Admin Email: <input type="text" value="[email protected]" name="admin[admin_email]" id="admin_email"><br> 
     Site Logo: <input type="file" name="site[logo]" id="site_logo"><img width="150px" height="100px" src="http://localhost/grublies/public/images/Atomic-Bomb-Explosion-600x450.jpg"><br> 
     Records Per Page in user side: <input type="text" value="12" name="admin[rpp_user]" id="rpp_user"><br> 
     Records Per Page in admin side: <input type="text" value="15" name="admin[rpp_admin]" id="rpp_admin"><br> 
     Site Address: <textarea name="admin[site_address]" id="site_address">C 136</textarea><br> <input type="submit" value="Submit" id="" name=""> </form> 

如果我使用POST方法後形式在PHP提交,然後它會創建這樣如何發佈二維數組在jquery ajax其中name =「admin [email]」?

Array 
(
    [admin] => Array 
     (
      [admin_name] => Vipul Sharma 
      [admin_email] => [email protected] 
      [rpp_user] => 12 
      [rpp_admin] => 15 
      [site_address] => C 136 
     ) 

) 

一個數組,但我想可以通過jQuery AJAX張貼了這個相同的陣列,但遺憾的是其考慮管理[ADMIN_NAME]以一個變量 。我用jQuery序列化,它沒有工作?

回答

0

我認爲這將有助於你在我已經改變了一些屬性,你看到的HTML表單提交仔細

<html> 
    <script src="jquery-1.7.2.js"></script> 
<head> 
</head> 
<body> 
    <div id="mainfomr"> 
<form enctype="multipart/form-data" method="post" name="settingsForm" id="settingsForm"> 
     Admin Name: <input type="text" value="Vipul Sharma" name="admin[admin_name]" id="admin_name"><br> 
     Admin Email: <input type="text" value="[email protected]" name="admin[admin_email]" id="admin_email"><br> 
     Site Logo: <input type="file" name="site[logo]" id="site_logo"><br> 
     Records Per Page in user side: <input type="text" value="12" name="admin[rpp_user]" id="rpp_user"><br> 
     Records Per Page in admin side: <input type="text" value="15" name="admin[rpp_admin]" id="rpp_admin"><br> 
     Site Address: <textarea name="admin[site_address]" id="site_address">C 136</textarea><br> <input type="button" value="Submit" id="formsubmit" name=""> </form> 
</body> 
<script> 
    $("#mainfomr").on("click", "#formsubmit", function(event){ 

     var order = $("#settingsForm").serialize() 
    $.post("yourphpfile.php",order, function(data){ 

    }); 
    }); 
    </script> 
</html>