dongyan5239 2016-05-01 15:23
浏览 224
已采纳

如何提取URL并将其存储到MySQL?

I have a textarea in which user enter url and link is extracted successfully and appended to a div. How can I store that extracted data into database as the extracted data is in a div not in any input?

<textarea id="get_url" placeholder="Enter Your URL here" class="get_url_input" spellcheck="false" ></textarea>
<input type="button" value="Share">
<div id="results">
</div>

Extracted data is shown in result div, do I need to store the response into any hidden input and check if it is empty while clicking on share button?

  • 写回答

2条回答 默认 最新

  • dongxian7471 2016-05-01 15:48
    关注

    There are several ways to do this but I would recommend using:

    Ajax and JQuery

    In your JavaScript file add:

    var data = $('#div id').text(); 
        $.ajax ({
               url: "www.websitename.com/addurl.php",
        type: 'POST',
        data: { urltoadd: data},
        success: function (response){
           If (response = 'successful'){
    return true;
    }else {
    return false;
    }
        }
        });
    

    Now in your addurl.php file:

    <?php 
    $urltoadd = $_POST ['urltoadd'];
    
    ... add Code to save $urltoadd in your database. 
    
    If (file was added successfully){
    echo 'successful';
    }else {
    echo 'failed';
    }
    ? >
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R
  • ¥15 在线请求openmv与pixhawk 实现实时目标跟踪的具体通讯方法
  • ¥15 八路抢答器设计出现故障
  • ¥15 opencv 无法读取视频
  • ¥15 用matlab 实现通信仿真
  • ¥15 按键修改电子时钟,C51单片机
  • ¥60 Java中实现如何实现张量类,并用于图像处理(不运用其他科学计算库和图像处理库))
  • ¥20 5037端口被adb自己占了