zond zond - 4 months ago 8
Ajax Question

IE not obviously works with ajax

There are many related questions and answers (1), but I can't solve my problem
with ajax request. It works perfect on all browsers excepting IE. IE won't perform success block.

script:

<script>
$.ajax({
type : 'post',
async : false,//testing for IE
cache : false,
dataType : 'text',
url : '${pageContext.request.contextPath}/pages/recordInsert',
data : $('#newPlace #place').serialize(),
success : function(data, textStatus) {
console.log('record inserted');
loadPlaces();//reloading data in div
}
});
</script>


And controller:

@RequestMapping("pages/recordInsert")
public ResponseEntity<String> placeInsert(@ModelAttribute("place") Place place) {
@SuppressWarnings("unused")
///some useful code
Integer temp = placeService.insertPlace(place);
return new ResponseEntity<String>(HttpStatus.OK);
}


But when i start in IE Developer Tools (F12) all works perfect in IE too.
Versions: IE 9, jquery 2.1.4

Answer

Replace this line:

console.log('record inserted');

with

if (window.console) console.log('record inserted');