NameSilo

Ajax browser problems

Spacemail by SpaceshipSpacemail by Spaceship
Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
Watch

Wuoshi

Established Member
Impact
8
I have the following script in a .js-file:
Code:
var xmlHttp

function showProducts(str)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 
 
var strs = str.split('_');
 
var str1=strs[0];
 
var str2=strs[1];
 
var str3=strs[2];
 
 
var url="list.php?"
url=url+"&subcat="+str1
url=url+"&cat="+str2
url=url+"&bra="+str3
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("ajaxy").innerHTML=xmlHttp.responseText 
 } 
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

I call the script using the following HTML:


<a href="#" value="category_subcategory_brand_.html" onclick="showProducts(this.value)" >link</a>


It's working in IE, but no other browsers, any ideas? In FF and other browsers except IE the variable "str" comes up as undefined.

Thanks on beforehand.
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
I don't think there is a value attribute for the A tag so your code is not valid. Use another property like this.href or another tag.
 
0
Close
You're right! It worked like a charm when I used this.id instead!

Thank you!
 
0
Close
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Filters for activity feeds
Your news feed, Latest activity, and the activity tab on profiles now have filter buttons: All, Posts, Quick replies, and Other. Your...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back