$ .ajax内部加载功能不起作用

时间:2013-04-13 18:27:05

标签: php jquery ajax

如何序列化这个表格数据在load function.it的序列化唯一的无线电值。当我点击更改值并点击“保存”按钮ajax只适用于无线电...问题可能是什么?

Javascript

$(document).ready(function() {

$("#pard_configure_a").click(function() {

        $("#pard_admin").load('../pard_admin/view/configure.php', function() {




            $(":submit").click(function(event) {
        event.preventDefault();


        var data = $("#pard_site_configuration").serialize();
$("#hhh").html(data);
        $.ajax({

            url: "../controller/configure.controller.php",
            type: "POST",
            data:data,

            success: function(responce) {
                //$("#res").html(responce);

            }
        });



    });





});
});


}); 

HTML

<div id="pard_configure">
<p>
<form  id="pard_site_configuration" method="post">
 <fieldset>
<legend >Site Configuration</legend>
<!-- Site Settings-->
<div id="pard_site_settings">
<label class="pard_site_settings">Site Settings</label>
<div class="input-prepend">
<span class="add-on">Site Title</span>
<input class="span6" id="prependedInput" type="text" >
</div>
<br/>
<div id="pard_site_offline_radio" class="input-prepend">
<span class="add-on">Site Offline</span>

<label id="radio_1" class="radio">

<span class="add-on">ON</span>

<input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked>
</label>
<label id="radio_2" class="radio">
<span class="add-on">OFF</span>
<input type="radio" name="optionsRadios" id="optionsRadios2" value="option2">

</label>
</div>
<div class="input-prepend">
<span class="add-on">Admin Email</span>
<input class="span3" id="prependedInput" type="text" placeholder="example@domain.com">
</div>
<div class="input-prepend">
<span class="add-on">Meta Description</span>
<br/>
<textarea rows="3"></textarea>
</div>
<div class="input-prepend">
<span class="add-on">Meta Keywords</span>
<br/>
<textarea rows="3"></textarea>
</div>
<div class="input-prepend">
<span class="add-on">Copyright</span>
<br/>
<textarea rows="3"></textarea>
</div>
</div><!-- Site Settings end-->
<!-- Database Settings-->
<div id="pard_database_settings">
<label class="pard_database_settings">Database Settings</label>
<div class="input-prepend">
<span class="add-on">Host</span>
<input class="span2" id="prependedInput" type="text" placeholder="localhost">
</div>
<div class="input-prepend">
<span class="add-on">Database Name</span>
<input class="span2" id="prependedInput" type="text" placeholder="database">
</div>
<div class="input-prepend">
<span class="add-on">Database Username</span>
<input class="span2" id="prependedInput" type="text" placeholder="Username">
</div>
<div class="input-prepend">
<span class="add-on">Database Password</span>
<input class="span2" id="prependedInput" type="text" placeholder="Password">
</div>
</div><!-- Database Settings end-->
<div id="pard_admin_form_button">
<input id="pard_site_configuration_submit" class="btn btn-small btn-primary" type="submit" value="Save"/>
<input class="btn btn-small" type="submit" value="Close" /></div>
</fieldset></form>
</p><div id="hhh"></div></div>

在id =“hhh”

中序列化结果
optionsRadios=option1

注意我将id =“hhh”设置为查看序列化数据的临时场所

1 个答案:

答案 0 :(得分:1)

确保您在所有表单输入中都有name属性:

<input name="someName" class="span6" id="prependedInput" type="text" >

您的代码适用于单选按钮,因为它们具有name属性。当您使用.serialize()时,这会忽略没有名称属性的元素。