0
I’m having problems with caching a page because there are three calls in the event of .change();
of 3 input[type='select']
asynchronous with jQuery
, but when I make a new seal on the first select
, for some reason cache of the old value sent to the page by asynchronous.
Anyway, is there any other alternative to $("#minhaDiv").html('');
to clear the entire contents of the DIV
?
There are 3 selects with 3 Divs:
<html>
<select id='select1' name='select1'>
<option value='1'>1</option>
<option value='2'>2</option>
</select>
<select id='select2' name='select2'>
<option value='1'>1</option>
<option value='2'>2</option>
</select>
<select id='select3' name='select3'>
<option value='1'>1</option>
<option value='2'>2</option>
</select>
<div id='divSelect1'></div>
<div id='divSelect2'></div>
<div id='divSelect3'></div>
<script>
$(document).ready(function(){
$("#divSelect1").on('change', function(){
$('#divSelect2').empty();
$('#divSelect3').empty();
var cat_four_value = $(this).val();
$.ajax({
type: 'POST',
url: 'push/' + cat_four_value + '/',
data: { value: cat_four_value },
cache: false,
success: function(data){
$('#divSelect1').load('select-details/1');
}
});
}
$("#divSelect2").on('change', function(){
$('#divSelect3').empty();
var cat_four_value = $(this).val();
$.ajax({
type: 'POST',
url: 'push/' + cat_four_value + '/',
data: { value: cat_four_value },
cache: false,
success: function(data){
$('#divSelect2').load('select-details/1');
}
});
}
$("#divSelect3").on('change', function(){
var cat_four_value = $(this).val();
$.ajax({
type: 'POST',
url: 'push/' + cat_four_value + '/',
data: { value: cat_four_value },
cache: false,
success: function(data){
$('#divSelect3').load('select-details/3');
}
});
}
);
</script>
</html>
I don’t know what your code looks like, because it didn’t post. But an alternative could be to use the method remove() jQuery.
– LeAndrade
@Leandrade removes(); does not also delete div ?
– AngeloJ
@sam did not solve the problem, it is equal to html('').
– AngeloJ
@Leandrade need to remove only the same internal content, do not delete the DIV, because it is not created, it is only fed content in the event.
– AngeloJ
@Angeloj your question wants an alternative to
.html('')
, in this case, is the.empty()
. Now, whether or not you solved your problem is another story. D... but let’s take a closer look...– Sam
I raised the question, maybe help me help myself.
– AngeloJ
Yeah, like I said I didn’t see your code 'cause I didn’t post it!
– LeAndrade
The code has several errors. Parentheses are missing to close the events after the
}
.– Sam
It is that I typed here, but in the console no error, but I will close the topic, I will redo in another way, I thought and I thought and I decided to do it in a simpler way. Thank you for everything and attention paid, beast success!
– AngeloJ