Welcome Guest, Not a member yet? Register   Sign In
SimpleXML/Ajax/Internet Explorer problems
#1

[eluser]MARKNEUBURGER[/eluser]
Hi,

I'm working on a web application that allows for a div to have its contents filled into automatically via a jQuery Ajax request. The contents of the div are a parsed XML file. I am doing the parsing with SimpleXML (not the CodeIgniter version, as I'm running PHP 5.2.9 and have access to it as part of my PHP installation).

Everything works great in every browser except Internet Explorer (6, 7, and 8). Loading the exact same page, I get PHP errors from IE that do not appear in the other browsers, which function as expected.

The first error occurs at the second of these two lines, in my XML parser function:
Code:
$dininghall_node_array = $menu->xpath("//dininghall[@name=\"".$dininghall."\"]");
$dininghall_node = $dininghall_node_array[0];

The error is "Undefined offset: 0".

If I insert a block of code like the following directly after these two lines:
Code:
if (isset($dininghall_node)) echo "Variable set!"
else echo "Variable not set! :("
then in internet explorer, "Variable not set! Sad" is printed and in every other browser "Variable set!" is printed. This problem is frankly boggling my mind because I have no idea how a server side script is producing two different results based on whether or not the browser is IE.

Any thoughts?

Thanks,
Mark
#2

[eluser]LuckyFella73[/eluser]
You are right, server side code is basicly independent of the browsertype
you are using. Your problem seems to be that the IEs don't send
the needed value to your php code so you will have to check your
ajax script.

Please post your ajax function then I'm sure somebody aroud this
forum is able to help you.
#3

[eluser]n0xie[/eluser]
Be wary of javascript in IE. Make sure the syntax is completely accurate. IE javascript parser is much less forgiving than Firefox or Opera, so one omitted ';','}' or ')' and your code will not run correctly.
#4

[eluser]MARKNEUBURGER[/eluser]
Spot on. Thanks much, it was indeed the javascript. For some reason, IE was appending an extra space to the variables i was posting. I never figured out why this was, but using trim() on the variables when they got to PHP solved the problem.




Theme © iAndrew 2016 - Forum software by © MyBB