I had a realtivley simple ajax application, which I have broken up to be more modular. The code is at the link below, and what I have mainly done is add the GetRecordSet function and allowed fetchcompelte to take a variable for which layer to put data in. It should work fine in thery. When I put alert()s in, the code seems to execute, except for inside either of the if clauses in fetchcomplete.
http://www.nomorepasting.com/getpaste.php?pasteid=22558
This is the code for get_records.php, which again seems like it should be fine
http://www.nomorepasting.com/getpaste.php?pasteid=22559
and this is the original index php file
Firsly I would agree with Shyam and also install Firebug for Firefox; this will be a huge help for javascript debugging.
anyway, the line
will assign the result of
FetchComplete(layername)toxmlHttp.onreadystatechange, which isn’t what you want. It would need to beBut then you have the problem of passing
layername.If you define the onreadystatechange as an anonymous inner function you can easily use variables defined outside it, so you could do something like this:
layeris defined as a local variable in GetAuctionData() but is accessible in the anonymous function, because you are creating a Closure. Note that I haven’t tested the above function, but it should work in principle.