Solved

Json firefox not working, but IE ok.

Posted on 2009-05-14
9
1,003 Views
Last Modified: 2013-12-08
Hi - I have some php code that outputs 4 variables as "yes" or "no", which is called from submitting a form. I'm echoing this as an array and an ajax script is picking it up via a json output.

This works fine in IE, i.e. the script finds the ajax response and processes fine. But in firefox, it stops at the ajax response and I just see the array echoed in the browser as {"var1":"no","var2":"no","var3":"no","var4":"no"}  and nothing happens.

Any ideas?
$myArray = array(
     'var1' => $var1,
     'var2' => $var2, 
	 'var3' => $var3,
	 'var4' => $var4 
); 
 
echo json_encode($myArray);

Open in new window

register.txt
ajax-register.txt
0
Comment
Question by:michaelbrewitt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
9 Comments
 
LVL 1

Author Comment

by:michaelbrewitt
ID: 24390548
Sorry, I forgot to mention, the above works in Firefox if I access /register.php directly. But, loading register/php through a <div>, it breaks as described above.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 24414907
Please post the Javascript part of the AJAX code in a snippet.  Also the html for the part of the page the script works with.
bol
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 24414915
Could you also look and see if you get a Javascript error in Firefox when you try this?  Provide details if you are getting an error.
bol
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 1

Author Comment

by:michaelbrewitt
ID: 24425226
See attached.

Index page loads and first loads the login.php file into a div. If you click on "register" it then loads register.php as attached above.

Incidently, I can get this working fine with the login.php file - it's just the register version which doesn't work.

No errors in firefox/firebug.

Many thanks
index.txt
login.txt
0
 
LVL 1

Accepted Solution

by:
michaelbrewitt earned 0 total points
ID: 24446463
Got it! I removed the $(document).ready() enclosure and bingo, all working fine!
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 24446594
Great!  Thanks for letting me know.   Since I was still just getting attached files I had hesitated to look into this more (I am more cautious about what I download than just what I see in a snippet).
Had you sent me the email with the URL and other info?  I got one but didn't get a URL for the EE question.  I am pretty sure it was you and this one but please confirm.
bol
0
 
LVL 1

Author Comment

by:michaelbrewitt
ID: 24453902
Yes, I sent you an email with the URL.
Glad it's working now, spent way too much time trying to sort it. Thanks for taking the time to have a look.
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question