1,105,556 Community Members

ajax dont open php file

Member Avatar
hwoarang69
Posting Pro
572 posts since Feb 2012
Reputation Points: -4 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 9 [?]
 
0
 

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.
Member Avatar
pritaeas
mod_pritaeas
11,315 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
0
 

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."

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article