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 stc15f2k60s2单片机关于流水灯,时钟,定时器,矩阵键盘等方面的综合问题
  • ¥15 YOLOv8已有一个初步的检测模型,想利用这个模型对新的图片进行自动标注,生成labellmg可以识别的数据,再手动修改。如何操作?
  • ¥30 NIRfast软件使用指导
  • ¥20 matlab仿真问题,求功率谱密度
  • ¥15 求micropython modbus-RTU 从机的代码或库?
  • ¥15 django5安装失败
  • ¥15 Java与Hbase相关问题
  • ¥15 后缀 crn 游戏文件提取资源
  • ¥20 bash代码推送不上去 git fetch origin master #失败了
  • ¥15 LOL外服加入了反作弊系统,现在游戏录像rofl文件离线都无法打开