My code is not giving output on first button click,
When i click on button for very first time, it returns nothing. When i click it for two or three time i can able to get the response.
Here is my code :
var newMask = new Ext.LoadMask(Ext.getBody(), {msg:"Getting Item Details..."});
if(''!=itemCode) {
newMask.show();
Ext.Ajax.request({
url:'searchP20code',
method:'POST',
params:{itemCode:itemCode,serialNumber:serialNumber},
success: function(response) {
newMask.hide();
var checkForRes=Ext.decode(response.responseText);
if(checkForRes!=null)
{
document.getElementById('p20_code').value = checkForRes.p20VICode;
document.getElementById('material_description').value = checkForRes.materialDesc;
Ext.getCmp('country').setValue(checkForRes.country);
var countryValue=checkForRes.country;
if(countryValue !=null && countryValue!="No Code Found") {
var countryStore = Ext.getCmp('country').getStore();
countrycode= countryStore.findRecord("countryName", countryValue).get('countryCode');
}
else
{
countrycode = null;
}
document.getElementById('countryId').value=countrycode;
// document.getElementById('countryValue').value=checkForRes.country
formelement.elements["countryValue"].value=checkForRes.country
document.getElementById('matl_type').value = checkForRes.materialType;
document.getElementById('printIP').value = checkForRes.printerIP;
document.getElementById("printBtn").disabled = false;
document.getElementById('serial_number').focus();
}
else
{
newMask.hide();
Ext.getCmp('country').setValue("");
document.getElementById("printBtn").disabled = true;
Ext.MessageBox.alert('', 'No data found.');
}
/*var countryVal=checkForRes.result;
if(checkForRes.result=="No Code Found") {
Ext.getCmp('country').setValue("");
} else {
Ext.getCmp('country').setValue(countryVal);
}*/
},
i’m calling this function itemCodeValidate() in button click event
function itemCodeValidate()
{
var vItemCode, text;
vItemCode = document.getElementById("item_code").value;
vItemCode = vItemCode.replace(/\s*$/,"");
document.getElementById("item_code").value = vItemCode; searchP20code();
}
searchP20code()
this method is the above mentioned code,
in my browser developer tool for first click i can able to see JSON error, not able to decode the response.
All i need is to know what is happening in first click and second click. Open for you guys and thanks for your support as well…