click jquery button + send data without form - bookmark

前端 未结 3 961
太阳男子
太阳男子 2021-01-17 22:13

I\'m working on a bookmarking function where the user clicks on a jQueryui button and certain information is sent to the database. But I\'m not using a form, because there i

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-17 22:57

    Instead of using .ajax() use either .get() or .post()

    Using .get()

     $.get('controller/addBookmark',function(data){ 
         alert('Your bookmark has been saved'); 
     });
    

    Using .post()

     $.post('controller/addBookmark', function(data) {
         alert('Your bookmark has been saved, The contents of the page were:' + data); 
     });
    

提交回复
热议问题