Код, показанный ниже, использует Ajax, но есть неопределенная полоса загрузки, как будто функция никогда не вызывается из контроллера. Как мне получить HTML-код для успешного запуска этой функции?
//HTML
<button type="button" data-url="/ajax/controller.php" name="dosubmit" class="wojo button positive">Approve</button>
<input name="ProcessApproval" type="hidden" value="1">
//Function
public function ProcessPOApproval()
{
$PID = $_GET['pid'];
$ApprovalTransactionalData = array(
'PONum' => "$PID",
'Step' => "4"
);
self::$db->insert("accounting_transact", $ApprovalTransactionalData);
}
//Controller
<?php
/* == Proccess Project File == */
if (isset($_POST['ProcessApproval'])):
if (intval($_POST['ProcessApproval']) == 0 || empty($_POST['ProcessApproval'])):
die();
endif;
ProcessPOApproval();
endif;
?>
//Ajax
/* == Master Form == */
$('body').on('click', 'button[name=dosubmit]', function() {
posturl = $(this).data('url')
function showResponse(json) {
if (json.status == "success") {
$(".wojo.form").removeClass("loading").slideUp();
$("#msgholder").html(json.message);
} else {
$(".wojo.form").removeClass("loading");
$("#msgholder").html(json.message);
}
}
function showLoader() {
$(".wojo.form").addClass("loading");
}
var options = {
target: "#msgholder",
beforeSubmit: showLoader,
success: showResponse,
type: "post",
url: SITEURL + posturl,
dataType: 'json'
};
$('#wojo_form').ajaxForm(options).submit();
});
Ниже приведен HTML-код с идентификатором wojo_form согласно запросу.
<form id="wojo_form" name="wojo_form" method="post">
<div class="three fields">
<div class="field">
<label>Submitting Accountant</label>
<label class="input"><i class="icon-prepend icon calendar"></i>
<input type="text" value="" disabled="disabled" name="created">
</label>
</div>
<div class="field">
<label>Next Approval</label>
<label class="input"><i class="icon-append icon calendar"></i>
<input type="text" value="<?php echo $row->lastlogin;?>" disabled="disabled" name="lastlogin">
</label>
</div>
<div class="field">
<label>Approval Group</label>
<label class="input"><i class="icon-prepend icon laptop"></i>
<input type="text" value="<?php echo $row->lastip;?>" disabled="disabled" name="lastip">
</label>
</div>
</div>
<div class="wojo double fitted divider"></div>
<button type="button" data-url="/ajax/controller.php" action="" name="dosubmit" class="wojo button">Decline Approval</button>
<input name="ProcessDecline" type="hidden" value="1">
<button type="button" data-url="ajax/controller.php" name="dosubmit" class="wojo button positive">Approve</button>
<input name="ProcessApproval" type="hidden" value="1">
<button type="button" data-url="/ajax/controller.php" name="dosubmit" class="wojo button info">Add Notes</button>
<input name="ProcessNotes" type="hidden" value="1">
</form>
Если вам нужно что-то еще, пожалуйста, дайте мне знать.