i am new to ajax and not sure why this isnt working. when user click on link in index.php than ajax should run. in ajax it will open a cart_del_item.php file where the main code will run. this way the page wont reload every time user hit the link in index.php.

the problem is in jquery.js file. for some reason it wont open cart_del_item.php file.

index.php

<a href='cart.php?del_id=$image_id_db' id='linkx' name='linkx'>
            <img src='IMAGE/x.png' id='imgx' />
</a>

jquery.js

$('#linkx').click(function()
{ 

    $.ajax({
        type: 'POST',
        url: 'cart_del_item.php',    
        data: 'del_id_d=' + 2
    });
});

cart_del_item.php
<?php
include("include/connect.php");

if(isset($_POST['del_id_d']))
{
    $del_id_p = $_POST['del_id_d'];

    $delete_query = mysql_query("DELETE FROM item_cart WHERE item_id = '$del_id_p'") or die(mysql_error());
}

?>

in jquery.js i also trying putting this:

}).complete(function(){
        //alert('ajax request complete - might be error ex value string has numbers?'); 
    }).success(function(){
        //alert('ajax request success - Every thing works');



    the complete works but success doesnt work.

Don't know what version you are using, but the jQuery site states: "Deprecation Notice: The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callbacks are deprecated as of jQuery 1.8. To prepare your code for their eventual removal, use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead."

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.