PHP Snippet 2:
<?php echo CHtml::ajaxSubmitButton('Form Ajax Submit Button',
CHtml::normalizeUrl(array('/site/about')),
array('success'=>'function(){$("#mydialog").dialog("close");}',
'update'=>'#myDiv' ),
array('name' => 'run', 'class' => 'btn btn-success')
); ?>
PHP Snippet 3:
<?php echo CHtml::ajaxSubmitButton('Form Ajax Submit Button',
CHtml::normalizeUrl(array('/planning/xlsAbsences')),
array(
'type'=>'POST',
'beforeSend' => "function(request) { console.log('beforeSend'); }",
'data'=>'js:$("#select-year-form").serialize()+"&year="+$("#dropDownId :selected").text()',
'success'=>'function(response, status, request){
$("#mydialog").dialog("close");
var disp = request.getResponseHeader("Content-Disposition");
if (disp && disp.search("attachment") != -1) {
var filename = disp.substring(21).replace("\"","");
var form = $("<form method=\"POST\" action=\"index.php?r=planning/dl\">");
form.append($("<input type=\"hidden\" name=\"content\" value=\"" + request.responseText + "\">"));
form.append($("<input type=\"hidden\" name=\"filename\" value=\"" + filename + "\">"));
$("body").append(form);
form.submit();
}
console.log(filename);
console.log(request.responseText);
}',
'complete' => "function(request) { console.log(request); }",
'error' => "function(data) { alert('erro'+data); }",
),
array('name' => 'run', 'class' => 'btn btn-success')
); ?>