On success, I would like to show different values depending on what value exists. For example, if $(‘#add’).val() has a value in it I would like to show ‘Video added” as part of the success function. If $(‘#remove’).val() has a value in it, I would like to show ‘Video removed’ as part of the success function. Either #add or #remove will have a value in it at a given time. How do I enable this?
<script type="text/javascript">
$(document).ready(function() {
$("#test").submit(function(event){
event.preventDefault();
$.ajax({
type:"POST",
url:"/edit_favorites/",
data: {
'video_add': $('#add').val(), // from form
'video_remove': $('#remove').val() // from form
},
success: function(){
$('#message').html("<h2>Video added!</h2>")
}
});
return false;
});
});
</script>
If you are sure that only one of the textfields will have a value, you could do something like this: