0

Im having this piece of code

<div id="status">content here</div>
 <input name="order_data" type="button"  value="<?php echo $order;?>"  class="besttocart"  onclick="gotocart(this);" />

and Javascript

function gotocart(e)
{       
   var origtext = $('#status').html();
    if(getCookie('language').toLowerCase() == 'en'){
   $('#status').html('Loading');
    }else{
    $('#status').html('het laden');        
    }

   $.ajax({           
            url: 'index.php?route=foo/bar',
            type: 'post',
            async:false, /*I strongly suspect something here*/
            dataType:"json",
            success:function(data){

               //do stuff
            }
    });


}

The issue is in Google chrome $('#status').html() is changing to "loading" or "het laden" when i look through console.but it is not showing in my page my status content is still "content here". working fine in firefox

coolguy
  • 7,866
  • 9
  • 45
  • 71

2 Answers2

0

I guess the issue is with this line:

getCookie('language'),

because when I changed the code like this,

   var origtext = $('#status').html();

    var str=getCookie('language');

   //changed the code here

    if(str && str!='' && str.toLowerCase() == 'en'){
   $('#status').html('Loading');
    }else{
    $('#status').html('het laden');        
    }

this works fine.

When the cookie is not set, the function getCookie is returning blank, but toLowerCase is not parsing it in Chrome. Hence the error.

luckystars
  • 1,704
  • 12
  • 12
-1

Did you try using

document.getElemetnById("status").innerHTML="SOMETHING";
Ram
  • 845
  • 1
  • 13
  • 26