PDA

View Full Version : Just upgraded from 4.0.2 to 4.0.7 and no getting call to undefined method 'split'


harkbj
11-21-2007, 06:51 AM
Hello, I have just upgraded from 4.0.2 to 4.0.7 and I am now getting the following error :

call to undefined method 'split'

This happens on the following line
<script>
<![CDATA[
.
.
.
canvas.languagesArray = null;
canvas.languages = null;
//*** Get all of the languages from the index.jsp
LzBrowser.callJS('getLanguages',function(res){canv as.languages = res;});
canvas.languagesArray = canvas.languages.split("***");
.
.
.
]]>

</script>

Can anyone tell me why this is happening ???

senshi
11-21-2007, 01:52 PM
some notes...

//initial value for both fields is null
canvas.languagesArray = null;
canvas.languages = null;

//you call a js-function on your browser and you define a callback-function,
//which sets the "canvas.languages" field, (after the js-function returned, for sure..)
LzBrowser.callJS('getLanguages',function(res){canv as.languages = res;});

//you access the "canvas.languages" field,
//but did you ensure that the callback-function had already finished!?
canvas.languagesArray = canvas.languages.split("***");

harkbj
11-22-2007, 11:45 PM
Hi Senshi,

thanks for your response. I didn't realise I had to check that the call back function had already finished. I assumed that the statement after the LzBrowser.callJS(...) would not execute until the call back function had completed.

If this is not the case then would you be able to give me some idea as to what would be the best way to ensure that the canvas.languagesArray = canvas.languages.split("***"); is only executed after the call back function has completed ??

Thanks in advance for your help.

senshi
11-26-2007, 12:36 PM
What about placing the "split"-stuff within the callback-function?


canvas.languagesArray = null;
canvas.languages = null;

LzBrowser.callJS('getLanguages', function(res) {
canvas.languages = res;
canvas.languagesArray = canvas.languages.split("***");
});