weixin_33713707 2020-03-07 17:21 采纳率: 0%
浏览 24


This question already has answers here:
                    <div class="grid--cell mb0 mt4">
                        <a href="/questions/13822322/jquery-how-to-clear-an-element-before-appending-new-content" dir="ltr">Jquery: How to clear an element before appending new content?</a>
                            <span class="question-originals-answer-count">
                                (4 answers)
            <div class="grid--cell mb0 mt8">Closed <span title="2020-03-07 17:36:39Z" class="relativetime">last month</span>.</div>

I've recently started using and learning JS and jquery. I'm sending a user email from a form to my PHP page to check if any user exists in DB via ajax, then I get a response from my PHP file if the user exists or not and display the text in a div. It's working fine, but because the page doesn't refresh when the button for sending form data is pressed, ajax just stacks the response from PHP.

I probably need to clear the response every time the button is clicked first and then append the response but I can't find the right command for it :/


function sendnewpass() {
        var email = document.getElementById("useremail").value;

            type : "POST",
            url  : "login.php", //my php page
            data : { passemail : email },  //passing the email
            success: function(res){  //to do if successful
                $("#emailsentmsg").append(res);  //the the div that i put the response in

  • 写回答



      相关推荐 更多相似问题


      • ¥15 c++字符串分割问题
      • ¥15 关于#sql#的问题:没有用命令关闭cdc,手动把系统表开启的cdc右键删除了
      • ¥15 android freedom
      • ¥15 使用自定义的类型代替内置类型可行吗
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题
      • ¥15 win11如何运行geoserver
      • ¥15 审稿意见请教-用ERNIE进行小样本分类的对比实验问题
      • ¥15 gem5搭建arm v8