jquery - if(isset($_POST.... not being set with ajax request -
i'm having zii.widgets.jui.cjuidialog
box send form via ajax controller. however, when test controller presence of post if(isset($_post['item']))
. isn't present , don't know why. i'm adapting post http://www.yiiframework.com/wiki/145/cjuidialog-for-create-new-model/
fit own needs.
this form within model:
<div class="form"> <form id="email-item-form" action="/www.mywebsite.ca/item/1/my-first-item" method="post"> <div id="email-item-success" class="label label-success"></div> <div id="email-item-failure" class="label label-important"></div> <div class="row"> <label for="item_email_item">email item to:</label> <input placeholder="send to..." name="item[email_item]" id="item_email_item" type="text" /> <div class="errormessage" id="item_email_item_em_" style="display:none"></div> </div><!-- row --> <div class="row"> <label for="item_email_item_sender">email sent from:</label> <input placeholder="sent from..." name="item[email_item_sender]" id="item_email_item_sender" type="text" /> <div class="errormessage" id="item_email_item_sender_em_" style="display:none"></div> </div><!-- row --> <br /> </form>
controller
public function actionemail($id) { if(isset($_post['item'])) { // rest of code } }
the data being sent via chtml::ajax
, declaring 'type'=>'post'
. process has been working in terms of sending item id controller , sending responses modal box. problem has started since tried confirm presence of $_post['item']
in order set $model->attributes=$_post['item'];
any in solving great thank you.
update show chtml::ajax()
var url = '<?php echo yii::app()->createurl("item/email", array("id"=>$model->id)); ?>'; <?php echo chtml::ajax(array( 'url'=>'js:url', 'data'=> "js:$(this).serialize()", ....// rest of code
i don't see inputs or other form data name="item"
. however, if change php code exact names of form, should find them:
public function actionemail($id) { if(isset($_post['item[email_item_sender]'])) { // rest of code } }
edit:
if want see post data debugging purposes, can use code php: possible automatically posted data?
foreach ($_post $key => $value) echo "field ".htmlspecialchars($key)." ".htmlspecialchars($value)."<br>";
Comments
Post a Comment