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!
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.
Call your function like this:
window.top.window.stopUpload(<? echo $result; ?>,'<? echo $file_name; ?>');
Hope it helps.
Try this :
window.top.window.stopUpload('<? echo $result; ?>','<? echo $file_name; ?>');
Remember, $result should not be any numerical value. User $result = '1' instead.
And change success == '1') in your if statement.
Hope it helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.