Get Form Input via Ajax
Posted
by
user3651491
on Stack Overflow
See other posts from Stack Overflow
or by user3651491
Published on 2014-06-03T03:06:17Z
Indexed on
2014/06/03
3:25 UTC
Read the original article
Hit count: 154
I have a jqgrid plugin which I call via Ajax. I have index.php and a getGridData.php. How will I pass form input in getGridData.php via ajax and use it in getGridData.php? I tried serialize but I can't pass or access it on getGridData.php. I need it as parameters for mysql. Here's my code.
<script language="javascript" type="text/javascript">
function jgGrid()
{
$(document).ready(function () {
$("#grid").jqGrid({
url: "inc/Controller/getGridData.php"+$("#thisForm").serialize(),
data : formData,
datatype: "json",
mtype: "POST",
colNames: ["SiteID", "TerminalID", "TransactionType", "Amount", "ServiceStatus"],
colModel: [
{ name: "SiteID"},
{ name: "TerminalID"},
{ name: "TransactionType"},
{ name: "Amount"},
{ name: "ServiceStatus"},
],
pager: "#pager",
rowNum: 10,
rowList: [10,20],
sortname: "SiteID",
sortorder: "asc",
height: 'auto',
viewrecords: true,
gridview: true,
caption: ""
});
});
}
</script>
getGridData.php
include('../Model/Queries.php');
$cardnumber = $_POST['cardnumber'];
$transact_type = $_POST['transact_type'];
$fromdate = $_POST['fromdate'];
$todate = $_POST['todate'];
$loyalty = new Queries();
$get_mid = $loyalty->loyaltyConn($cardnumber);
$somedata = json_encode($loyalty->nposConn($get_mid, $transact_type, $fromdate, $todate));
echo $somedata;
© Stack Overflow or respective owner