I am using a jQuery ajax post function to enter a new row in the database and then output some HTML on .done()
It works well with out putting it into a function. But for some reason when I add this to a function it stopped working. Can anyone please help me figure this out?
Below is my code
Function page:
function add_items(){
    var id = ($(this).attr("id"));
    //Insert a new row using an ajax post method, post the the id to reference
    //under which category the menu item should go under
    var adtnl_item = $.post("ItemCreate.php", {id : id })
    .fail(function(){
        console.log( "New Row Can't be added" );
    })
    //Append the new menu item input fields to the div class
    //.menu_item_wrapper that has an id of the mainØ category ID
    .done(function(data) {
         return $('.menu_item_wrapper[id="' + id + '"]').append(data);
    });
}
Index page:
    $(".add_item").on("click", function(){
        add_items();
    });
 
     
    