dongliangkeng1056 2015-11-30 11:02
浏览 66
已采纳

骨干保存? 出现在URL中

when i do a save an ? sign appears in the URL, before the #

http://localhost:8000/html/WebChecker/www/?#signin

The code of the save is the next

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});
            }
        });

And the php post function is:

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){

If anybody knows the reason...

Thank you

  • 写回答

1条回答 默认 最新

  • dpauf28808 2015-12-01 11:47
    关注

    Thank you Marc Greenstock, that was the answer. event.preventDefault makes the event wait (I think thats how preventDefault works).

    Thank you so much!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ssh登录页面的问题
  • ¥60 渗透一个指定银行app,拿到客户信息,需要什么级别
  • ¥50 关于在matlab上对曲柄摇杆机构上一点的运动学仿真
  • ¥15 jetson nano
  • ¥15 :app:debugCompileClasspath'.
  • ¥15 windows c++内嵌qt出现数据转换问题。
  • ¥20 公众号如何实现点击超链接后自动发送文字
  • ¥15 用php隐藏类名和增加类名
  • ¥15 算法设计与分析课程的提问
  • ¥15 用MATLAB汇总拟合图