Sebastian
Sebastian

Reputation: 83

Javascript works in Chrome, Safari and Opera but not Firefox

Site here.

Basically the box in the middle doesn't generate random string from my database in Firefox as it does in the other browsers. I can't seem to find the problem, my JS skills aren't amazing.

I haven't tested it in IE as I don't have access to it right now.

Any ideas?

Thank you!

Upvotes: 2

Views: 778

Answers (3)

Yi Jiang
Yi Jiang

Reputation: 50105

The following error is generated when you view the site in Firefox:

Error: form is not defined
Source File: http://saucydares.freehostia.com/saucy.php
Line: 29

The line in question is

$.post ('data.php', {name: form.name.value, mode: mode, player: player},

I think the correct method for what you're doing here (if I interpret what you're doing here correctly) is to obtain the form's name with jQuery.

Upvotes: 0

Ankit Jaiswal
Ankit Jaiswal

Reputation: 23427

Check the error message in firebug:

form is not defined

$.post ('data.php', {name: form.name.value, mode: mode, player: player}, 

Upvotes: 0

Nick Craver
Nick Craver

Reputation: 630389

The problem is that form is not defined where you're using it in firefox, you could write it a bit differently to be cross-browser compatible like this:

function get() {
  $('#dare').fadeOut(500);

  $.post ('data.php', $("form").serialize(), function(output) {
    $('#dare').html(output).fadeIn(500);
  });
}

The .serialize() function will take every input element in the form a serialize it, resulting in the same request all the other browsers are making...in a lot less code :)

Upvotes: 2

Related Questions