Sorry, another question... I just playing arround with different
possibilities:
$(document).ready(function(){
// on default, disable the submit button
$(".requestbutton").attr("disabled", "disabled");
function check_how_many_products_checked(){
$.ajax({
type: "POST",
url: "/ajax_add_selected_product_to_session.php",
success: function(msg){
/* add here what to do on success */
return msg;
}
});
}
var x = "";
x = check_how_many_products_checked();
alert(x);
The alert is always "undefined"...
Why? I must return the figure 2, what it does, if I alert the msg
directly.
Sorry for these questions, I am just about to learn the syntax.
Thanks!
On 25 Feb., 10:57, heohni <[email protected]>
wrote:
> Ok, thanks a lot!!
>
> On 25 Feb., 10:38, system div <[email protected]> wrote:
>
> > var how_many_checked= '';
>
> > $.ajax({
> > type: "POST",
> > url: "/ajax_add_selected_product_to_session.php",
> > success: function(msg){
> > /* add here what to do on success */
> > //alert(msg);
> > how_many_checked = msg;
>
> > }
> > });
> > alert(how_many_checked);
> > if(how_many_checked !=undefined) {
> > do some..................................................
>
> > }
>
> > On Wed, Feb 25, 2009 at 5:31 PM, heohni
>
> > <[email protected]> wrote:
>
> > > Hi,
>
> > > $.ajax({
> > > type: "POST",
> > > url: "/ajax_add_selected_product_to_session.php",
> > > success: function(msg){
> > > /* add here what to do on success */
> > > //alert(msg);
> > > var how_many_checked = msg;
>
> > > }
> > > });
> > > alert(how_many_checked);
> > > if(how_many_checked > 0) .......
>
> > > the FF returns "how_many_checked" ist not defined.
> > > Why?
>
> > > How can I define a var and use it for a later coming if / else part?
>
> > > Thanks a bunch!