Php Firebug显示帖子信息,但我无法回复
我有一个表单,在通过AJAX提交后似乎可以成功发布。在Firebug的网络下,张贴的信息正确显示。但我根本无法回应这些数据 我正在尝试这个,这是我表格中的第一个字段: 这是否与表单的操作没有url有关 此外,我试图将数据发布到同一页面,而不是PHP文件。也许这就是问题的一部分?这也是Wordpress页面,而不是文件 以下是实时url: 以下是表格代码:Php Firebug显示帖子信息,但我无法回复,php,jquery,ajax,forms,Php,Jquery,Ajax,Forms,我有一个表单,在通过AJAX提交后似乎可以成功发布。在Firebug的网络下,张贴的信息正确显示。但我根本无法回应这些数据 我正在尝试这个,这是我表格中的第一个字段: 这是否与表单的操作没有url有关 此外,我试图将数据发布到同一页面,而不是PHP文件。也许这就是问题的一部分?这也是Wordpress页面,而不是文件 以下是实时url: 以下是表格代码: <form id="quotation_form" name="vdmQuotationForm" action="#" method=
<form id="quotation_form" name="vdmQuotationForm" action="#" method="post">
<div id="page1">
<div id="step0_header" class="steps-headers" onClick="step0ToggleClick();">Step 1<span style="margin-left:30px;">Sun Exposure</span></div>
<div id="step0" class="quotation-steps"><strong>Describe the sun exposure of your planter...</strong><br/>
<div class="radio-container"><input onchange="go_to_next_step();" type="radio" name="sun_exposure[]" id="full_sun" value="Full Sun"<?php checked( 'Full Sun',$_POST['sun_exposure[]']); ?> /><label class="label-quotation-steps">Full Sun</label><br class="clear"/></div>
<div class="radio-container"><input onchange="go_to_next_step();" type="radio" name="sun_exposure[]" id="part_sun" value="Part Sun"<?php checked( 'Part Sun',$_POST['sun_exposure[]']); ?> /><label class="label-quotation-steps">Part Sun</label><br class="clear"/></div>
<div class="radio-container"><input onchange="go_to_next_step();" type="radio" name="sun_exposure[]" id="full_shade" value="Full Shade"<?php checked( 'Full Shade',$_POST['sun_exposure[]']); ?> /><label class="label-quotation-steps">Full Shade</label><br class="clear"/></div>
</div>
</div>
</div>
</form>
尝试打印print\u r$\u POST;然后检查页面中是否有任何重定向。嗨@messi fan,它打印数组,并且没有重定向。谢谢你说你在同一个页面上使用了$\u POST。您的意思是与ajax函数在同一页面上吗?在这种情况下,难怪您的$\u帖子不起作用。@user007,是的,这是正确的,我将数据发布在与AJAX函数相同的页面上。“那么这就行不通了?”罗布米里克:是的,我只是试了一些短的东西。使用var\u dump$\u POST;在同一页面上,返回整个页面代码以及HTML。如果您通过AJAX和echo json\u encode$\u POST发送到不同的文件;在该文件上,它返回已发布的值。
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#quotation_form').validate({ // initialize the plugin
rules: {
'sun_exposure[]': {
required: true,
},
'height[]': {
required:true,
},
'diameter[]': {
required:true,
},
'shape[]': {
required:true,
},
'placement[]': {
required:true,
},
},
messages: {
'sun_exposure[]': {
required: 'Please choose a sun exposure for your plant',
},
'height[]': {
required: 'Please choose the height of your planter'
},
'diameter[]': {
required: 'Please choose the diamter of your planter'
},
'shape[]': {
required: 'Please choose the shape of your planter'
},
'placement[]': {
required: 'Please choose the placement of your planter'
},
},
errorPlacement: function (error, element) {
alert(error.text());
},
submitHandler: function (form) { // for demo
alert('valid form submitted'); // for demo
var form_data = $("#quotation_form").serialize();
$.ajax({
url: "http://www.richmindonline.com/container-creations/personal-creations-assistant/",
type: 'POST',
data: form_data,
cache: true,
success: function(data) {
alert(data);
}
});
$('#page1').hide();
$('html, body').animate({ scrollTop: $('body').offset().top }, 10);
$('#page2').show();
$('.intro').hide();
$('.to_page1').show();
return false;
}
}); // end .validate()
});
</script>