Google Chrome sendet Request zwei mal?

tsbmusic

Erfahrenes Mitglied
Hi Leute,

also ich hab da mal wieder ein Problem undzwar hab ich bei meiner Website ein Ajax-Request für die Formulare eingebaut und wenn ich das in Firefox oder IE ausprobiere dann funktioniert das auch, nur in Google Chrome wird das anscheinend zwei mal versendet weil alles doppelt in der Datenbank gespeichert wird.

Gibts da irgendeinen bekannten Bug oder so etwas?

Gruß
tsbmusic
 
Also das ist das Formular:
HTML:
<form action="messages.php?sk=new" method="post">
   <input type="hidden" name="to_user" value="{implode(',', $users)}" />
   <input type="hidden" name="response_to" value="{$mid}" />
   <div class="inputContainer">
    <textarea class="textBox noResize" name="message" onfocus="Live.setControl(this)"></textarea>
   </div>
   <div class="uiControl uiActions">
    <input type="submit" name="answer" value="{$smarty.const._ANSWER}" />
   </div>
  </form>

Und hier die PHP-Datei:
PHP:
if(isset($_POST['message']) && isset($_POST['to_user'])){
    $message = $_POST['message'];
    $to_user = $_POST['to_user'];
    $response_to = ($_POST['response_to']) ? $_POST['response_to'] : 0;
    $from_user = $thisUser->uid;
    $GLOBALS['DB']->query(sprintf("INSERT INTO messages (response_to, from_user, to_user, message, created_at) VALUES (%u,%u,%u,'%s','%s')", $response_to, $from_user, $to_user, $message, time()));
    $message = $GLOBALS['DB']->query("SELECT * FROM messages WHERE from_user = $from_user ORDER BY created_at DESC LIMIT 1");
    $message = $message[0];
    if(isset($_POST['__a'])){
      if($response_to != 0){
        $message["to_user"] = new User($message["to_user"]);
        $message["from_user"] = new User($message["from_user"]);
        $template = new Smarty();
        $template->assign("message", $message);
        $content = $template->fetch("messages/view_message.html");
        $data["content"] = $content;
        $data['target'] = ".uiMessageStream";
        $data['addType'] = 1;
        $data['js'] = "jQuery('.uiComposer').find('textarea').val('').blur();";
      } else {
        $data['js'] = "Dialog.showMessage('" . _MESSAGE_SENT . "', '" . _MESSAGE_SENT_TEXT . "', 2);";
      }
      header("Content-Type:application/json");
      echo return_js($data);
    } else {
      header("Location: messages.php?sk=view&v=message&id=" . $message['id']);
    }
  } else {
    if(isset($_REQUEST['__a'])){
        $template = new Smarty();
        $content = $template->fetch("messages/new_message.html");
        $data['js'] = "Dialog.showMessage('" . _NEW_MESSAGE . "', '" . sendable_text($content) . "')";
        header("Content-Type:application/json");
        echo return_js($data);
        exit();
      } else {
        header("Location: messages.php");
      }
  }

Und noch Javascript:
Javascript:
var Form = {
  init: function(){

  },
  storeButton: function(a){
    var element = new Array();
    element['name'] = $(a).attr("name");
    element['value'] = $(a).attr("value");
    this._storage = element;
  },
  inlineSubmit: function(a){
    if(this._storage){
      var form_data = $(a).serialize()+"&"+"__a=1"+"&"+this._storage['name']+"="+this._storage['value'];
    } else {
      var form_data = $(a).serialize()+"&"+"__a=1";
    }
    $.ajax({
      type: $(a).attr("method") || "POST",
      url: $(a).attr("action"),
      data: form_data,
      success: function(response){
        processData(response);
      }
    });
    return false;
  }
}
$("form:not(.noLive)").live("submit", function(){
    return Form.inlineSubmit(this);
  });
$("input[type=submit],button[type=submit]").live("click", function(){
    return Form.storeButton(this);
  });
 

Neue Beiträge

Zurück