Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
50
rated 0 times [  51] [ 1]  / answers: 1 / hits: 18899  / 12 Years ago, sat, february 2, 2013, 12:00:00

i need help with this one. I have my function working well with ajax, but i need a ok / cancel delete confirmation box before i send ajax request in order to remove item from database. This is my code:



delete_article = function(article_id){
$.ajax({
type:POST,
url: <?php echo base_url()?>admin/article/delete_article,
data: article_id=+article_id,
asynchronous: true,
cache: false,
beforeSend: function(){

},
success: function(){
$('#articletr'+article_id).hide();

}

});
}
})

More From » jquery

 Answers
7
var answer = confirm (Are you sure you want to delete from the database?);
if (answer)
{
// your ajax code
}


If you want more control over these kinds of modal dialog prompts with JQuery (buttons that say something other than OK/cancel, more than two buttons, or different styles), you can use JQuery UI Modal Confirmation.


[#80463] Friday, February 1, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
josh

Total Points: 391
Total Questions: 112
Total Answers: 90

Location: Aruba
Member since Fri, Jun 24, 2022
2 Years ago
josh questions
Wed, Aug 4, 21, 00:00, 3 Years ago
Mon, Aug 24, 20, 00:00, 4 Years ago
Wed, Aug 12, 20, 00:00, 4 Years ago
;