Form submition with jQuery is not working correctly with IE8

后端 未结 5 1580
广开言路
广开言路 2021-01-24 09:40

jQuery $.ajax() does not seem to work correctly with IE8 but it is working with Firefox, Chrome and Safari. I am submittin the form and response back in JSO

5条回答
  •  情深已故
    2021-01-24 10:07

    instead of

    for(var id in data) {
      jQuery('#' + id).html( data[id] );
    }
    

    have you tried using $.each() ?

    jQuery.each(data , function(id, val) {
      jQuery('#' + id).html( val );
    });
    

    and also, you have misinterpret $(this), (I guess)

    jQuery('.ajaxform').live('submit', function(event) {
    
      var $this = $(this); // add this line...
    
     $.ajax({
            url  : $this.attr('action'),
            type : $this.attr('method'),
            dataType: 'json',
            data : $this.serialize(),
            success : function( data ) {
         for(var id in data) {
          jQuery('#' + id).html( data[id] );
         }
                }
        });
    
     return false;
    });
    

提交回复
热议问题