Safari interprets 'submit()' as method 'POST'

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rynato@gmail.com

    Safari interprets 'submit()' as method 'POST'

    I ran into an interesting problem while working on a form:

    I have a drop down list (think <form><select>< option>...) of 'open
    sessions' which a user can choose from to continue entering data.
    There is a small bit of javascript which, when the 'onChange' event
    occurs, triggers a 'submit' which reloads the page and displays the
    stored values for that session using a session ID variable named,
    '$existingSessi ons'.

    Even though the form's method is set to "GET", Safari insists on
    seeing this as a "POST" as a result of the javascript submit call,
    while all other browsers I tested (Firefox/Mac, IE/Mac, Firefox/PC,
    IE7/PC) interpret this as a "GET".

    So at the top of the PHP script, $existingSessio ns =
    $_POST['existingSessio ns'] will ONLY work with Safari while all other
    browsers (which I tested) require $existingSessio ns =
    $_GET['existingSessio ns'] in order to retrieve the values.

    Has anyone else run into this issue? I handled it with a simple
    HTTP_USER_AGENT request and an if...else statement. Still, I'd like to
    know what's up with this! Is it just because Safari is a semi-sucky
    browser?

  • Mike P2

    #2
    Re: Safari interprets 'submit()' as method 'POST'

    On May 11, 10:53 am, ryn...@gmail.co m wrote:
    I ran into an interesting problem while working on a form:
    >
    I have a drop down list (think <form><select>< option>...) of 'open
    sessions' which a user can choose from to continue entering data.
    There is a small bit of javascript which, when the 'onChange' event
    occurs, triggers a 'submit' which reloads the page and displays the
    stored values for that session using a session ID variable named,
    '$existingSessi ons'.
    >
    Even though the form's method is set to "GET", Safari insists on
    seeing this as a "POST" as a result of the javascript submit call,
    while all other browsers I tested (Firefox/Mac, IE/Mac, Firefox/PC,
    IE7/PC) interpret this as a "GET".
    >
    So at the top of the PHP script, $existingSessio ns =
    $_POST['existingSessio ns'] will ONLY work with Safari while all other
    browsers (which I tested) require $existingSessio ns =
    $_GET['existingSessio ns'] in order to retrieve the values.
    >
    Has anyone else run into this issue? I handled it with a simple
    HTTP_USER_AGENT request and an if...else statement. Still, I'd like to
    know what's up with this! Is it just because Safari is a semi-sucky
    browser?
    To resolve this at the PHP end, you can just use $_REQUEST instead
    which is a combination of $_GET, $_POST, and $_COOKIE.

    To resolve this in the browser, you can create a submit button in the
    form next to the jumpbox, and in the onchange for the jumpbox do
    document.forms['whatever'].elements['goBtn'].click()
    Note that I mean the name attribute of the go/submit button is
    'goBtn'. This method will also allow people who don't have JavaScript
    enabled to use the go button to change the session. I've run into
    strange behavior with form.submit() before, and I had to use
    submitBtn.click () instead. I'm not absolutely sure this solution will
    fix your problem at the browser end, but it usually fixes my problems
    with form.submit().

    -Mike PII

    Comment

    Working...