5May/070
Strange Javascript Behaviour
Yeah... I'm dumb. But, how do I know that this simple code generate quite difficult to understand error?
function buildParameter(scr, txt){
var returnValue = "";
var temp = txt.split("\n");
returnValue = '<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?><request>'
+ '<script>' + scr + '</script>';
for(i = 0; i < temp.length; i++){
x = temp[i].split('=');
returnValue += '<param name="' + x[0] + '">' + x[1] + '</param>';
}
returnValue += '</request>';
alert(returnValue);
return returnValue;
}
Go a head, test it with your editor. Here, I got
unterminated string literal
And how do I know what is generating this error?. You know what? Here's the suspect :
returnValue = '<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?><request>' + '<script>' + scr + '</script>';
I don't know why is this generating error and I'm googling without result. Maybe wrong query. But, I found the solution by trial and error. So, here's the weapon to terminate this suspect :
returnValue = '<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?><request>' + '<' + 'script' + '>' + scr + '</' + 'script>';






No comments yet.
No trackbacks yet.