Cross Origin in ajax not working for .properties file in IOS (10.3.1)
I used i18n plugin for load *.properties file for translation and its working fine on android platform but same library not working on IOS 10.3.1. It gives me below error:
i have done some changes in i18n library but still its not working.
function loadAndParseFile(filename, settings) {
$.ajax({
url: filename,
async: false,
cache: settings.cache,
crossDomain: true,
jsonpCallback: 'callback',
contentType: 'text/plain;charset=" + settings.encoding,
dataType: "text',
success: function (data, status) {
parseData(data, settings.mode);
}
});
}
In above code:
i have been added Cross-Domain ‘true’ and datatype ‘text’.. when i changed datatype ‘text’ to ‘jsonp’ its working but it gives .properties file error.
Please check below error..
That means. file is loaded, but inner data format is different.
If you are using now JSONP instead of text, the file will be loaded as javascript code, so if contents are not valid javascript code it will fail.
Surround data with a global variable assignation or a function call:
window.variable = "_DATA_"; // or
functionName("_DATA_");
If _DATA_ are JSON format, then you don’t need surround with quotes, otherwise you’ll need to use “_DATA_” because without quotes it will not be valid javascript syntax.