dop82210 2011-09-14 03:20
浏览 36
已采纳

如何调用保存,删除和删除所有函数,html jquery ajax和php

I am currently write a html page for uploading image, once the image gets upload, it automatically append underneath the upload section using ajax, so that people can start edit the uploaded image. here is my code for append the image, image description,radio button and check box

$('#thumbnails').append('<div id="imagediv' + str_idnum + '" style="border: 0px solid #aaa;text-align:left;padding:20px;"><div><img src="' + response + '" style="padding:10px; margin-right:20px; border-bottom: 2px solid #ccc;border-left: 2px solid #ccc;border-top: 2px solid #ddd; border-right: 2px solid #ddd;"  id="imageid' + str_idnum + '" align="left"/></div><div class="descriptionwrapper" style="border: 0px solid #aaa;"><textarea cols="40" rows="3" id="textarea' + str_idnum + '" onClick="SelectAll(\'textarea' + str_idnum + '\')" align="left" style="resize:none;">Optional description goes here...</textarea><br /><input type="checkbox" style="margin-top:-20px" name="delete" value="Delete" id="delete' + str_idnum + '"/>Delete<br /><input type="radio" name="setcoverpic" value="setcoverpic" id="setcoverpic' + str_idnum + '"/>Make this the front cover of set<br /><br /></div></div><br /><br /><br />');

here is the code for all the buttons to perform save, delete, delete all, function

   <div id="buttonbardiv">
    <div class="fancybuttonwrapper" style="margin-left:100px;"><span class="button">   <span>
    <input type="button" class="form_button" id="checkall" value="  Check all"></span> </span> </div>  
   <div class="fancybuttonwrapper" style="margin-left:316px; "><span class="button"><span>
        <input type="button" class="form_button" id="deletecheckedbutton" value="    Delete Checked Items"></span></span> </div>
      <div class="fancybuttonwrapper" style="margin-left:500px;"><span class="button"><span>
        <input type="button" class="form_button" id="finisheduploadingbutton" value="  Save and Exit">
      </span></span> </div>
        <div class="fancybuttonwrapper" style="margin-left:460px;"><span class="button"><span>
         <input type="button" class="form_button" id="gobackbutton" value="  Go Back">
        </span></span> </div>
  </div>       

      <div class="images" id="thumbnails">
     </div>

my question is that how I call ajax to perform the save, delete and delete all functions when the button get clicked, thanks!

  • 写回答

1条回答 默认 最新

  • dpjo15650 2011-09-14 03:28
    关注

    I think it depends on the way your application works. In a RESTful application, you would call those, for example:

    save: POST /things
    delete: DELETE /things/1
    

    And have a controller on your server that executes your requests. Basically, what you have to keep in mind is to associate HTTP requests (AJAX) to a script that controls actions in your database.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?