How can I access the value of $(this) after success: function() when using jquery? No matter what I've tried, it appears I cant do it.
$('.add').click(function() {
//etc etc
$.ajax({
type:"GET",
url:"/",
data:data,
dataType: 'json',
beforeSend:function(html){
//Nothing here right now
},
success: function(){
$(this).parent("div").after("<div class='flag'>I'm the new one.</div>");
},
<div id="container">
<div class="h1" data-id="1">Teachers <span class="add" data-id="US01">Add New</span></span>
</div>
<div class="flag">Flag</div>
<div class="edit">Edit</div>
<div class="h2" data-id="2">Who is your favorite Math teacher? <span class="add" data-id="US02">Add New</span></div>
<div class="flag">Flag</div>
<div class="edit">Edit</div>
<br>
<div class="h1" data-id="8">Restaurants <span class="add" data-id="US10">Add New</span></div>
<div class="flag">Flag</div>
<div class="edit">Edit</div>
<div class="h2" data-id="9">Which is your favourtie restaurant in town? <span class="add" data-id="US20">Add New</span></div>
<div class="flag">Flag</div>
<div class="edit">Edit</div>
</div>