0

the following code works fine in FF, opera and chrome but fails in IE

function get_modelo(modelo) {
        var selState = modelo;
        alert (selState);
        console.log(selState);
        $.ajax({    
            url: "site/ajax_call", //The url where the server req would we made.
            async: false, 
            type: "POST", //The type which you want to use: GET/POST
            data: "state="+selState, //The variables which are going.
            dataType: "HTML", //Return data type (what we expect).

            //This is the function which will be called if ajax call is successful.
            success: function(data) {
                //data is the html of the page where the request is made.
                $('#city').html(data);
            }
        })
    }

Can't understand the problem.

user1910232
  • 151
  • 1
  • 3
  • 12
  • Whenever I have a problem with IE returning HTML from an AJAX call, I first check to see if the HTML is valid. IE is not as forgiving if you've forgotten to close a tag or something. – swatkins Jan 22 '13 at 01:32
  • remove console.log line from your code.... this line stops executing other lines in ie – Code Prank Jan 22 '13 at 07:11

2 Answers2

3

console.log in IE doesn't work or causes problems.

See here: What happened to console.log in IE8?

and here: Testing for console.log statements in IE

and here: http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/

or just google search IE console log

Everything else in your code looks like it would work fine.

Community
  • 1
  • 1
Kai Qing
  • 18,793
  • 5
  • 39
  • 57
0

Try this. Below will work in IE8 :P

$.ajax({    
        url: "site/ajax_call", //The url where the server req would we made.
        async: false, 
        type: "POST", //The type which you want to use: GET/POST
        data: { state: selState }, //The variables which are going.
        dataType: "html", //Return data type (what we expect).

        //This is the function which will be called if ajax call is successful.
        success: function(data) {
            var newDiv = $('<div></div>');
            newDiv.html(data);
            newDiv.appendTo("#city");
        }
    });
Saleem
  • 1,059
  • 14
  • 27