I try to split a string at the colon and to check whether it was successful. The api.php gives me back a JSON.
$.ajax({
type: "POST",
url: "api.php",
data: { "somedata": "123"},
success: function (data, status, xhr) {
if (data.indexOf("text") != -1) {
var meinjson = $.parseJSON(data);
for (var key in meinjson) {
if (meinjson.hasOwnProperty(key) && key=="text") {
text = meinjson[key];
text = text.replace(/\+/g, " ");
text = decodeURIComponent(text);
if (text.indexOf(":") !== -1) {
text = text.split(/:(.+)?/);
var text1 = text[0];
var text2 = text[1];
}
if (text2 == undefined || text1 == undefined || text1 == void 0 || text2 == void 0 || text1=="" || text2=="") {
alert("fail");
}
}
}
}
}
});
I can not explain why the internet explorer to always fall into the last if but does not firefox and chrome. A example of data is:
{"command":"SENDTEXT","text":"Lorem+Ipsum","command":"SENDTEXT","text":"Lorem+Ipsum+dolor","specialcommand":"CONNECTACCEPT"}