Answer the question
In order to leave comments, you need to log in
Yii1 Form serrialize() not working, why?
Form submission not working.
Structure:
<form action="#" method="post" class="answer-form form-horizontal form-bordered" id="edit<?=$request->id?>">
<div class="clearfix">
<!-- Правая колонка заявки-->
<div class="col-sm-12 col-md-5 any-tariff">
...
</div>
<!-- Левая колонка -->
<div class="col-sm-12 col-md-7 extended-tariff">
...
</div>
<!-- Блок, скрывающий контакты от пользователей с базовым тарифом -->
<div class="col-sm-12 col-md-7 change-the-tariff <?if(!$rules):?>change-visible<?endif;?>">
...
</div>
<div class="form-group answer">
<label class="col-sm-12 col-md-8 control-label">
<label class="col-sm-3 control-label">Кол-во машин:</label>
<div class="col-sm-2">
<input type="number" class="form-control" id="trucks_count" min="1" step="1" maxlength="2" value="1" onkeyup="return proverka(this);" onchange="return proverka(this);" name="trucks_count">
</div>
<label class="col-sm-3 control-label">Цена, руб:</label>
<div class="col-sm-2">
<input type="text" class="form-control" value="<?=$request->price?>" id="price" onkeyup="return proverkaDecimal(this);" onchange="return proverkaDecimal(this);" name="price">
</div>
</label>
<div class="col-sm-12 col-md-4">
<button style="float: right;" type="button" class="btn btn-success saveRequest" id="saveRequest<?=$request->id?>">Ответить</button>
</div>
</div>
</form>
$('.oldRows').on('click', '.saveRequest', function(){
$.post("<?=$this->createUrl('/ajax/ansferToRequestShipping');?>",{data:$("#edit<?=$request->id?>").serialize()},function(data){
$("#status").html(data);
});
});
$.post("<?=$this->createUrl('/ajax/ansferToRequestShipping');?>",{data:$("#edit<?=$request->id?>").serialize()}
var a = $('#trucks_count').val();
var b = $('#price').val();
{data:$("#edit<?=$request->id?>").serialize()}
Answer the question
In order to leave comments, you need to log in
$.post("<?=$this->createUrl('/ajax/ansferToRequestShipping');?>",$("#edit<?=$request->id?>").serialize()...
In theory, this data should get there. Check what will happen in the console if you do this:
$('.oldRows').on('click', '.saveRequest', function(){
var data = $("#edit<?=$request->id?>").serialize();
console.log(data);
});
The solution is:
$(".saveRequest").on('click',function (){
var obj = $(this).parent().parent();
$.post("<?=$this->createUrl('/ajax/ansferToRequestShipping');?>",{data:obj.find('input').serialize()},function(data){
obj.next('.clearfix').find('h4').html(data);
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question