Reputation: 69
I'm having trouble getting this AJAX call to work in IE11. I have some dropdowns showing types of cars (Manufacturer and model). The problem comes when I choose Citroën. It should show me the types of models, but it shows nothing. I guess it has something to do with the ë
letter, but I can not get this script to work.
IE 11 writes this for Citroën: Citroà « n
. I do have the UFT-8 in the header of the site and it works fine in Firefox, Chrome and Edge. Can anybody see why?
$('#make').change(function(){
$.post( "../ajaxmodelcar?model="+this.value, function( data ) {
$('#model').html(data);
});
});
Upvotes: 2
Views: 33
Reputation: 337700
You need to encode the value before you send it in the URL. You can either do this yourself using encodeURIComponent()
:
$('#make').change(function(){
$.post('../ajaxmodelcar?model=' + encodeURIComponent(this.value), function(data) {
$('#model').html(data);
});
});
Or preferably you can provide an object to the data
property of $.post
and jQuery will encode it for you:
$('#make').change(function(){
$.post('../ajaxmodelcar', { model: this.value }, function(data) {
$('#model').html(data);
});
});
Upvotes: 2