zoukankan      html  css  js  c++  java
  • ajax的post请求

     1 <!DOCTYPE html>
     2 <html>
     3     <head>
     4         <meta charset="UTF-8">
     5         <title></title>
     6     </head>
     7     <body>
     8         <button id = "box">点击</button>
     9         <div class="vals">评论内容</div>
    10         
    11     </body>
    12     
    13     <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    14     <script>
    15         $(function () {
    16             
    17         
    18             $("#box").click(function () {
    19                 save();
    20             });
    21             
    22             function save () {
    23                 $.ajax({
    24                     url:"http://www.andyan.cn/hiphop/hiphop/createMusicSynthesis",
    25                     dataType: 'json',
    26                     type: 'post',
    27                     data: {
    28                         id:"",
    29                         songName:"小米",
    30                         author:"小明",
    31                         lyric:"申请上市",
    32                         audioFilePath:"./path"  //歌曲保存的路径
    33                     },
    34                     success: function (obj) {
    35                         console.log(obj)                             
    36                         var id = obj.data;
    37                         load(id)
    38                         
    39                     }
    40                 })
    41             }
    42             
    43             function load(id){
    44                 $.ajax({
    45                     url: 'http://www.andyan.cn/hiphop/hiphop/createComment',
    46                     dataType:'json',
    47                     type:'post',
    48                     data: {
    49                         id: id,
    50                         content: $('.vals').html()
    51                     },
    52                     success: function (data) {
    53                         console.log(JSON.stringify(data));
    54                         console.log(data);
    55                     }
    56                 })
    57             }
    58         
    59         })
    60     </script>
    61 
    62 
    63 </html>
  • 相关阅读:
    apicloud教程
    apicloud教程3 (转载)
    apicloud教程2 (转载)
    apicloud教程1 (转载)
    API CLOUD 快捷键
    JS IIFE写法
    php事件驱动
    JQuery实践--Why JQuery
    Jquery实践--精读开篇
    python 实践--新闻聚合
  • 原文地址:https://www.cnblogs.com/1032473245jing/p/7472173.html
Copyright © 2011-2022 走看看