javascript - IE8 and jQuery - problems with trim, length and AJAX -


my code looks this:

function loaddata() {      $.ajax({         url: "",         async: true,         method: 'post',         datatype: "json",         data: {             start: $('input[name=start]').val(),             stop: $('input[name=end]').val(),             week: $('#weekpicker').val(),             range:$('select[name=date_control]').val(),             type: 'loaddata'         },         beforesend: function(xhr, opts) {             if (!$('input[name=start]').val() && !$('input[name=end]').val()) {                 bootbox.alert('select date first!');                 xhr.abort();                 return false;             }          },         success: function(dane) {             ustawienia = dane.ustawienia;              // code here          },         error: function(dane) {             $('button[name=pokaz]').removeattr('disabled');             bootbox.alert(dane.responsetext);         }     }); } 

on ff, chrome , ie>8 works fine, problem ie8. instead perform success' function in ie displays error: enter image description here

line 337 in jquery is:

globaleval: function( data ) {     if ( data && jquery.trim( data ) ) {         // use execscript on internet explorer         // use anonymous function context window         // rather jquery in firefox         ( window.execscript || function( data ) {             window[ "eval" ].call( window, data );         } )( data );     } }, 

so i've remove jquery.trim( data )

and next have error: enter image description here

// args internal usage each: function( obj, callback, args ) {     var value,         = 0,         length = obj.length, //here line 357!         isarray = isarraylike( obj );      if ( args ) {         if ( isarray ) {             ( ; < length; i++ ) {                 value = callback.apply( obj[ ], args );                  if ( value === false ) {                     break;                 }             }         } else {             ( in obj ) {                 value = callback.apply( obj[ ], args );                  if ( value === false ) {                     break;                 }             }         }      // special, fast, case common use of each     } else {         if ( isarray ) {             ( ; < length; i++ ) {                 value = callback.call( obj[ ], i, obj[ ] );                  if ( value === false ) {                     break;                 }             }         } else {             ( in obj ) {                 value = callback.call( obj[ ], i, obj[ ] );                  if ( value === false ) {                     break;                 }             }         }     }      return obj; }, 

what can do, make works?

had same problem on ie8. json not valid format. need quotes around attributes. official json should have quotes, nowadays new browsers don't care.

var json = {     test: "a",  //wrong     "test": "a" //correct } 

used on server side:

javascriptobject translationsobject = new javascriptobject(); dictionary<string, string> translations = translator.gettranslations(key.languagecode); foreach (var pair in translations) {     if (pair.value != pair.key)         translationsobject.add("\"" + pair.key + "\"", pair.value); //needed <=ie8 } string translationsstring = "var translations = "; translationsstring += translationsobject.tostring(); translationsstring += ";"; return translationsstring; 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -