made changes to js ajax to delete task once pirate accepts task
moved js on function outside from nested on function