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!

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

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效