I have a really weird situation, I am calling my javascript function like this...
window.top.window.stopUpload(<? echo $result; ?>,<? echo $file_name; ?>);
Javascript function looks like this,
function stopUpload(success,filePath){
var result = '';
if (success == 1){
result = '<span class="msg">The file was uploaded successfully!<\/span><br/><br/>';
}
else {
result = '<span class="emsg">There was an error during file upload!<\/span><br/><br/>';
}
document.getElementById('f1_upload_process').style.visibility = 'hidden';
document.getElementById('f1_upload_form').innerHTML = result + '<input name="image_file" type="file" class="browse" /><input type="submit" name="submit_button" value="Upload" class="browse"/>';
document.getElementById('f1_upload_form').style.visibility = 'visible';
return true;
}
Above code does't execute stopUpload function.
However If I do like this,
window.top.window.stopUpload(<? echo $result; ?>);
and javascript like this,
function stopUpload(success){
var result = '';
if (success == 1){
result = '<span class="msg">The file was uploaded successfully!<\/span><br/><br/>';
}
else {
result = '<span class="emsg">There was an error during file upload!<\/span><br/><br/>';
}
document.getElementById('f1_upload_process').style.visibility = 'hidden';
document.getElementById('f1_upload_form').innerHTML = result + '<input name="image_file" type="file" class="browse" /><input type="submit" name="submit_button" value="Upload" class="browse"/>';
document.getElementById('f1_upload_form').style.visibility = 'visible';
return true;
}
With one one param, it works!
Question
Why it works with one param and not with 2? I have tried sending normal string like 'hello' instead of $file_name but still it does't call.
$resultor$file_nameisnull, in which case it would lead to bad syntax (i.e.window.top.window.stopUpload(,'hello')window.top.window.stopUpload('<? echo $result; ?>','<? echo $file_name; ?>');