General Question

klaas4's avatar

Ajax refresh in, guess what, IE.

Asked by klaas4 (2189points) May 18th, 2008

I’m doing this Ajax refresh thingy for on my site, but IE doesn’t load the page. IE6 doesn’t IE7 doesn’t. :@

Here’s the site, here’s the js and here’s the external file. I’m sooo new with Ajax, that I don’t have a clue about what to do…

I got the code from here (the last post), and I changed it a bit. But when using in IE, it just gives me a white page. It does show my background for a sec, but that’s it.

Can anyone help me?
Davey

Observing members: 0 Composing members: 0

5 Answers

paulc's avatar

Are you using the XMLHttpRequest directly on purpose? I don’t see anything wrong with your JavaScript in terms of the actual requests. However, you are declaring your response, responseold and responsecheck variables inside the handler method. You should declare them all outside of this method so that they’re accessible throughout – in your situation they will always be undefined each time the handler is invoked.

Anyway, on your site you’re already using the Prototype library. I’d suggest using it to handle your requests since its got a much nicer API than all that manual XMLHttpRequest object stuff. I can’t really test much more because you’ve got your numpa.js include commented out right now.

klaas4's avatar

Yeah, sorry for that. It’s back now.

I don’t know how to do such thing in prototype. Is it just
new Ajax.PeriodicalUpdater(status_box, numpa.php); ?

But where do I put that. In a function? In setInterval/setTimeout? I really have no idea.

paulc's avatar

You just need to initiate it once so the best place would be in an onLoad like you’ve already got.

Then if you decide to use the periodical updater:
new Ajax.PeriodicalUpdater(status_box, ‘numpa.php’, {frequency:30});

Or if you want a bit more control just make individual requests: new Ajax.Request(‘numpa.php’, {onSuccess:method_to_handle_response}); then just be sure to declare a method named “method_to_handle_response” that accepts a parameter that is the same as the ones you’re using now (you’re likely looking for param_name.responseText).

Hope that makes sense.

klaas4's avatar

If you look now, you’ll see a function with the above given code, but it doesn’t update…
Can you explain why?

paulc's avatar

Fluther’s Textile text markup modifies all text to quote “properly”. That is, it transforms matching quotation marks to opening and closing quotations. Change the characters around numpa.php to normal single quotes. The opening quote you coped and pasted in is illegal in JavaScript.

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther