asp.net mvc 4 - how can I change content in span after ajax success in MVC 4 -
<div> <span class="label">1</span> <a href="#" class="click">up</a> </div>
javascript
$('.click').click(function(){ //$(this).parent().find('.label').html(2); $.ajax({ .... success: function(result){ $(this).parent().find('.label').html(2); } });
});
if don't use ajax.post, value in change.. , when use, doesn't change.
i don't know happen? , how can fix it.
give me advices please.
$(this)
not referring link (its inside $.ajax()
function). assign label element javascript variable before make ajax call can accessed inside ajax function.
$('.click').click(function(){ var label = $(this).parent().find('.label'); // or $(this).prev('.label'); $.ajax({ .... success: function(result){ label.html(2); } });
Comments
Post a Comment