weixin_33720956 2017-08-24 05:25 采纳率: 0%
浏览 30

放在ajax上而不是卷曲

I have this curl URL to connect to couchDB.

curl -X PUT http://admin:ulacit@13.90.93.32:5984/test/"001" -d '{"name":"moises"}'

I saw a lot of questions with GET and POST but I didn't find an example with PUT.

Am I doing this the right way?

$.ajax({
                    crossOrigin: true,
                    url : 'http://admin:ulacit@13.90.93.32:5984/test/'+user,
                    type : 'POST',
                    processData: false,
                    dataType: 'json',
                    contentType: 'application/json',
                    data: {pass:pass,email:email},
                    success:function(result){
                        if(result!="error"){
                            alert("Registro Correcto, Proceda a entrar");
                            open("login.html","_parent" );
                        }else{
                            alert("Usuario Ya Utilizado");
                        }
                    },
  • 写回答

1条回答 默认 最新

  • weixin_33681778 2017-08-25 12:51
    关注

    The PUT HTTP verb is used to either:

    • create a database e.g. curl -X PUT http://localhost:5984/mydb
    • create a document in a database when you know the id of the document you wish to create e.g.

    # create a document with PUT with document id in the URL
    curl -X PUT -d '{"a":1,"b":2}' -H 'Content-type: application/json' http://localhost:5984/mydb/mydocid
    {"ok":true,"id":"mydocid","rev":"1-25f9b97d75a648d1fcd23f0a73d2776e"}
    

    which is the equivalent of:

    # create a document with POST with the document id in the body
    curl -X POST -d '{"_id":"mydocid","a":1,"b":2}' -H 'Content-type: application/json' http://localhost:5984/mydb/mydocid
    
    评论

报告相同问题?