troubleshooting Question

Jquery/Ajax Success or Failure

Avatar of benners70
benners70 asked on
4 Comments2 Solutions730 ViewsLast Modified:
Hi. The page below includes Jquery which detects if a delete link is clicked and if so, it triggers the ajax to delete an image. I want to add a "hidden" class to the the parent DIV if the Ajax is successful but I don't know how to keep hold of the ID of the closest DIV after the Ajax success.

Can some help me add hidden class to parent DIV if successful and alert an error if not succesful?

<!DOCTYPE html>
<html lang="en">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type='text/javascript' src=''></script></head>
<div class="pic_container">
  <div class="pic_item" id="1">
    <p><a href="#" class="delete" title="img1.jpg">Delete</a></p>
<div class="pic_container">
  <div class="pic_item" id="2"><a href="#" class="delete" title="img2.jpg">Delete</a>
<script type="text/javascript">
		var id = $(this).closest("div").attr("id");
		var form_data = 
			file_orig: 'data1',
			ajax: '1'
			url: "ajax_process.php",
			type: 'POST',
			data: form_data,
			success: function(msg) {
	return false;
Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros