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
    
    评论

报告相同问题?

悬赏问题

  • ¥15 使用VH6501干扰RTR位,CANoe上显示的错误帧不足32个就进入bus off快慢恢复,为什么?
  • ¥15 大智慧怎么编写一个选股程序
  • ¥100 python 调用 cgps 命令获取 实时位置信息
  • ¥15 两台交换机分别是trunk接口和access接口为何无法通信,通信过程是如何?
  • ¥15 C语言使用vscode编码错误
  • ¥15 用KSV5转成本时,如何不生成那笔中间凭证
  • ¥20 ensp怎么配置让PC1和PC2通讯上
  • ¥50 有没有适合匹配类似图中的运动规律的图像处理算法
  • ¥15 dnat基础问题,本机发出,别人返回的包,不能命中
  • ¥15 请各位帮我看看是哪里出了问题