Im starting to study ajax, and I did my first example reading a tutorial.
In my first example, Im deleting images from a gallery, without loadingmy page.
I have a jQuery function that executes when I click in my image with class "imagesdel", and then I get id of my image to use in my post.
$(function(){
var url = 'delImage.php';
$('.images ul').on('click','.imagesdel',function(){
var delId = $(this).attr('id');
$('.images ul li[id="'+ delId +'"]').css('background','green');
$.post(url,{action:'del_images',image:delId},function(){
window.setTimeout(function(){
$('.images ul li[id="'+ delId +'"]').fadeOut("slow");
},500);
});
return false;
});
And then in my del_images.php I get my action: $action = $_POST['action']; And I do my delete where id is like my $_POST['image'];
And this is works, When I click in my image I delete without load my page.
But Im not using ajax like $.ajax({}); So Im asking if $.post(URL,data,callback); can do the same of using $.ajax({})??
And if it is the same, when should we use one instead of other?