How can I ensure that my Ajax call retrieves data from the remote database based on the updated search criteria every time I click the search button? Currently, the system retrieves results based on the initial search criteria even after I modify it and click the search button again.
Any suggestions or solutions would be greatly appreciated. Thank you!
$('#openDialog').dialog({height:400, width:545, autoOpen:false});
$('#objectTypeSelected').selectable();
$('#searchBtnObjects').click(function (evt) {
searchBtnObjectsClick();
});
function searchBtnObjects() {
var types = [];
var begin = $("#minDate").val();
var end = $("#maxDate").val();
var selectedTypes = $(".ui-selected");
var typeString ="";
for (var i = 0; i < selectedTypes.length; i++) {
types[i] = $(".ui-selected")[i].id;
typeString=typeString+$(".ui-selected")[i].id+",";
}
if (objectsTable != null) {
var postData = {
ajaxRequest:document.helper.getPageName(),
directAjaxMode:true,
types:typeString,
begin:begin,
end:end}
objectsTable.jqGrid("setGridParam", {postData:postData});
objectsTable.trigger('reloadGrid');
}
else{
objectsTable = $('#objectList').jqGrid({
datatype:'json',
colModel:[
{name:"ID", label:messageDictionary["ID"], editable:false, formatter:cc_formatter, unformat:cc_unformatter, index:"ID"},
{name:"DATE", label:messageDictionary["DATE"], editable:false, formatter:'date', formatoptions:{srcformat:'d/m/Y H:i:s', newformat:'d/m/Y H:i:s'}, index:"DATE"}
],
mtype:'POST',
multiselect:true,
pager:'#objectsPager',
postData:{
ajaxRequest:document.helper.getPageName(),
directAjaxMode:true,
types:typeString,
begin:begin,
end:en},
url:'search/getObjects',
jsonReader:{ repeatitems:false, cell:"", id:"id", userdata:"jsonModel", root:"rows" },
ignoreCase:true,
height:80,
autowidth: true,
shrinkToFit:true,
sortname:'ID',
sortorder:"asc",
loadonce:true,
rowNum:30,
rowList:[30, 50, 100],
rownumbers:true,
viewrecords:true
}
);
}
}