I have the following form with some data that I need to send.
<form action="http://localhost/sp/index.php/daily_operation/turn_close" method="post" accept-charset="utf-8" id="form" name="form" class="form_cash"><br /> <input type="hidden" id="total_amount" name="total_amount" value="0">
<div>
<fieldset class="fieldset">
<legend>Billetes</legend>
<div class="row_form_div">
<label for="hundred_amount">100</label>
<input type="text" id="hundred_amount" name="hundred_amount" class="billet"/>
<input type="hidden" id="hundred_denomination_id" name="hundred_denomination_id" value="1">
</div>
<div class="row_form_div">
<label for="fith_amount">50</label>
<input type="text" name="fith_amount" id="fith_amount" class="billet"/>
<input type="hidden" id="fith_denomination_id" name="fith_denomination_id" value="2">
</div>
<div class="row_form_div">
<label for="twenty_amount">20</label>
<input type="text" name="twenty_amount" id="twenty_amount" class="billet"/>
<input type="hidden" id="twenty_denomination_id" name="twenty_denomination_id" value="3">
</div>
<div class="row_form_div">
<label for="ten_amount">10</label>
<input type="text" name="ten_amount" id="ten_amount" class="billet"/>
<input type="hidden" id="ten_denomination_id" name="ten_denomination_id" value="4">
</div>
<div class="row_form_div">
<label for="five_amount">5</label>
<input type="text" name="five_amount" id="five_amount" class="billet"/>
<input type="hidden" id="five_denomination_id" name="five_denomination_id" value="5">
</div>
<div class="row_form_div">
<label for="one_amount">1</label>
<input type="text" name="one_amount" id="one_amount" class="billet"/>
<input type="hidden" id="one_denomination_id" name="one_denomination_id" value="6">
</div>
</fieldset>
</div>
</form>
Before sending it I need to ask for a condition with the data of the form.
I build a jquery ui dialog to ask for the condition
<div id="dialog-confirm" title="¿Cerrar turno con diferencia?">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;">
</span>El desglose insertado no coincide con el total por concepto de operaciones. Esto significa que cerrará el turno con diferencia.
¿Está seguro?</p>
</div>
That I call with the following JQuery code:
$( "#dialog-confirm" ).dialog({
resizable: false,
autoOpen:false,
height:150,
width:340,
open:false,
modal: true,
buttons: {
"No": function() {
$( this ).dialog( "close" );
},
"Si": function() {
$("#form").submit();
$(this).dialog('close');
}
}
}
});
This is with the aim to send the data posted in the form but nothings happens.
I have also tried to do this with Ajax
"Si": function() {
$("#form").submit();
if (true) {
{
$.ajax({
type: "POST",
dataType: "json",
url: 'daily_operation/turn_close',
data: $("#form").serialize(), // serializes the form's elements.
success: function(data)
{
},
error: function(data) {
bValid = false;
}
});
}
$(this).dialog('close');
}
}
But remains without send nothing.
Could you please help me? Thanks in advance…
The question is if you are trying to send it traditional way or by using AJAX
This should send it but there are some problems (eg. IE requires that form contains submit button sic!). And this approach can create many problems. What i suggest is to use AJAX. For start try and see what happens. :