I am retrieving some data from the server which looks something like this: 1:some values@2: some other@3:some more . I parse it in the client and It works well with chrome but firefox seems to throw this error.
I even tried setting the dataType to text which didnt work as well. I searched SO for similar questions and found this to be matching. But I am accessing it through http only unlike the problem in this thread.
EDIT:
setInterval(function(){
if($thisUser)
$commonURL= "checkRequest.do?user="+$thisUser ;
else
$commonURL= "checkRequest.do?user=null";
$.ajax({
url:$commonURL,
contentType: "text/plain",
dataType: "text",
success:function(result){
if(result[0]=="1")
window.location="playGame.do";
else if(result[0]=="2"){
result1=result.substring(1,result.indexOf("@"));
resultTemp="";
for(i=0;i<result1.split(",").length-1;i++)
resultTemp += "<a href='#' class='oppRequests' id='"+result1.split(",")[i]+"'>"+result1.split(",")[i]+"</a>, ";
$('td#oppRequests').html(resultTemp);
resultTemp="";
$("a.oppRequests").click(function(){
$thisUser = $(this).html();
$.ajax({
url:"postRequest.do?confirm="+$thisUser,
success:function(result){
}});
});
}
}
});
},10000);
Pls help me out of this 🙂
somebody pls answer this :p I have got the proper way to achieve what i want yet I would like to know the problem.
One thing for sure that will solve your problem and speed up your script is if instead of parsing your own data format as text, you should use the built in JSON format. This is supported in jQuery by simply changing the ‘datatype’ parameter to ‘json’. This will allow you to simply access your results from the server using the ‘result’ var without having to do any string matches.
In essence, your returned string in JSON format should look something like this:
And you can access this with result[key1], result[key2] in your success function.
Creating JSON server side is easy, I’m not sure what language you are using but a lot of languages have built in JSON encode functions.