骨干保存?出现在URL中

时间:2015-11-30 11:02:33

标签: php backbone.js save

当我做一个保存?符号出现在#

之前的URL中
http://localhost:8000/html/WebChecker/www/?#signin

保存的代码是下一个

signin : function(){
        var logi = document.forms['signin']['name'].value;
        var mail = document.forms['signin']['email'].value;
        var passwd = document.forms['signin']['pass'].value;
        var hash = CryptoJS.SHA256(passwd).toString(CryptoJS.enc.Hex);
        var tkn=Math.random(9) * 123123123;
        var user = new User({'login' : logi, 'email' : mail, 'pass' : hash, 'token': tkn.toString(), 'recovery' : null, 'img': 'default.png'});
        //var user = new User({'user' : logi, 'pass' : hash});
        user.save({},{
            wait : true,
            success : function(response){
                alert("OK");
                alert(response.res);
                Backbone.history.navigate("", {trigger: true});
            },
            error : function(options){
                alert('ERROR');
                Backbone.history.navigate("#signin", {trigger: true});
            }
        });

php帖子功能是:

try{
        $pdo = conectar();
        $insertar = $pdo->prepare('INSERT INTO user (login, email, pass, name, token, recovery, img) VALUES (:login, :email, :pass, :name, :token, :recovery, :img ); ');
        $insertar->bindParam(':login', $data->login);
        $insertar->bindParam(':email', $data->email);
        $insertar->bindParam(':pass', $data->pass);
        $insertar->bindParam(':name', $data->login); 
        $insertar->bindParam(':token', $data->token);
        $insertar->bindParam(':recovery', $data->recovery);
        $insertar->bindParam(':img', $data->img);
        $insertar->execute();
        $id = $pdo->lastInsertId();
        echo "{'res' : 'ok', 'id' : ".$id."}";
        $pdo = null;
        //$pdo = null;
    }catch(PDOException $e){

如果有人知道原因......

谢谢

1 个答案:

答案 0 :(得分:0)

谢谢Marc Greenstock,这就是答案。 event.preventDefault使事件等待(我想这就是preventDefault如何工作)。

非常感谢你!