AJAX Forums

What's wrong with this...

This is a discussion on What's wrong with this... within the AJAX Help forums, part of the Beginners AJAX category; Hi all! Could anyone tell me why this wont work... The function works when i remove the (ver) after "stateChanged" (inside showCat function). What I'm doing is ...


Go Back   AJAX Forums > Beginners AJAX > AJAX Help

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
Old 06-09-2007, 11:28 PM   #1 (permalink)
Junior Member
 
Join Date: Jun 2007
Posts: 1
Rep Power: 0 jboesch is on a distinguished road
What's wrong with this...

Hi all! Could anyone tell me why this wont work...
The function works when i remove the (ver) after "stateChanged" (inside showCat function). What I'm doing is I want to use this function more than once, so Im combining PHP to throw in a variable in showcat(str,ver). The ver is where the integer goes and auto-increments using a for loop that is being called through PHP
This is my PHP... (which works fine)..

<select name="blah" onchange="showCat(ver,$i)">
<option>blah</option>
</select>

... however the ajax wont work!

Please help!

<script type="text/javascript">
var xmlHttp

function showCat(str,ver)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="getcat.php"
url=url+"?id="+str
xmlHttp.onreadystatechange=stateChanged(ver)
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged(ber)
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("txtHint"+ber).innerHTML=x mlHttp.responseText
}
}

function GetXmlHttpObject()
{
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}
</script>

Last edited by jboesch; 06-09-2007 at 11:49 PM.
jboesch is offline   Reply With Quote
Old 06-12-2007, 12:28 PM   #2 (permalink)
Junior Member
 
Join Date: Jun 2007
Location: Slovakia
Posts: 5
Rep Power: 0 jsakalos is on a distinguished road
Send a message via Skype™ to jsakalos
Just at the first glance...

str and ver are reversed in function call and function declaration. I'm not saying that this is the cause for sure...

Have you tried to use Firebug to see if there are any javascript errors?
__________________
Jozef Sakalos, aka Saki
Web Page
jsakalos is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
What happens if I put wrong information of the CSS/Profile? sarah c XHTML and CSS 0 11-02-2007 08:49 AM
can someone tell me whats wrong with this javascript? liam uk JavaScript 1 06-26-2007 03:53 AM


All times are GMT -4. The time now is 10:17 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5
Copyright ©2006 - 2008, AJAXwith.com