PDA

View Full Version : how can I stop Ajax Call?



masudcseku
Dec 05, 2010, 3:59 PM
I am using an ext.Button for making some ajax call. I want to a client method to check some condition and then allow the post backing the entered value, but I found that despite of my checking of the client method, the button is automatically postbacking the values entered.
Here is the code


<ext:Button ID="MakePaymentButton" OnClientClick="return check_errors()"
runat="server" Text="Purchase Subscription">
<Listeners>
<Click Handler="Coolite.AjaxMethods.purchase_the_subscription(
{
success:showresult
}
)" />
</Listeners>
</ext:Button>


here is the client function that returns true or false after checking some condition


var check_errors=function()
{
var errors="";
var elem_prefix="ctl00_ContentPlaceHolder1_";

//credit card type
var ccdl=document.getElementById( elem_prefix + "CCDDL");
if(ccdl.selectedIndex<2)errors="Please select a card type.";

//card number
var cardnumber=document.getElementById(elem_prefix +"CardNumTextBox");
if(cardnumber.value=="")errors+="\nPlease enter your card number";
else{
if(testCreditCard()==false)
errors+="\nPlease enter a valid formatted credit card";
}

//expired date
if(checkExpiredDate()==false)
errors+="\nPlease enter a valid expired date";

//cVV number
var cvvNum=document.getElementById(elem_prefix +"CVVTextBox");
if(cvvNum.value=="")errors+="\nPlease enter your CVV number";

//first name
var fname=document.getElementById(elem_prefix +"FnameTextBox");
if(fname.value=="")errors+="\nPlease enter your first name";
//last name
var lname=document.getElementById(elem_prefix +"LnameTextBox");
if(lname.value=="")errors+="\nPlease enter your last name";

//billing address
var baddress=document.getElementById(elem_prefix +"AddressTextBox");
if(baddress.value=="")errors+="\nPlease enter your billing address";

//city
var city=document.getElementById(elem_prefix +"CityTextBox");
if(city.value=="")errors+="\nPlease enter your city name.";

//state
var state=document.getElementById(elem_prefix +"StateTextBox");
if(state.value=="")errors+="\nPlease enter your state";

//country code
var ccode=document.getElementById(elem_prefix +"CountrycodeTextBox");
if(ccode.value=="")errors+="\nPlease enter your country codes";
else{
var ccode_value=ccode.value;
if(ccode_value.length!=2)
errors+="\nCountry code must be of 2 digits";
}

alert("hey");
//now checking the error message
if(errors!="")
{
alert(errors);
//Ext.Msg.alert("Error!","Please correct the following errors to proceed:\n"+errors);
return false;
}
else return true;


}


Anybody, can you tell me how can I do that?

Daniil
Dec 07, 2010, 9:35 AM
Hi,

Please try



<Click Handler="if (check_errors()) { Coolite.AjaxMethods. ... }" />

masudcseku
Dec 19, 2010, 8:13 PM
Hi,

Please try

<Click Handler="if (check_errors()) { Coolite.AjaxMethods. ... }" />

thanks that worked. But I need to know the basic difference that
of Ext.Msg.confirm(" "," ") and confirm()

I found the confirm() worked for me but not the first. Whenever I try to check confirmation using the first one, I am getting dumb as it is avoiding my response and making the ajax call.

So, what is use of it?

geoffrey.mcgill
Dec 19, 2010, 8:21 PM
So, what is use of it?

More information available in the MessageBox docs, see

http://dev.sencha.com/deploy/dev/docs/?class=Ext.MessageBox