Solved

Json firefox not working, but IE ok.

Posted on 2009-05-14
9
997 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
  • 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now