[英]jquery ' Uncaught ReferenceError not defined' error message in chrome console
chrome控制台中出现某些错误消息,并且未显示预期结果。 无法确定是由哪个代码段产生的。 所以找不到其他方式,我在这里粘贴了代码
控制台说:
未捕获的参考错误:meraj_63193201111201321808488_white未定义
它给出的行号是95。
但是在第95行,我有:
alert(“ success value =” + arg2);
我想做什么 :
使用jquery-ui
,我使用了一个对话框来上传图像文件。 文件上传后,我想在photo_upload_preview_indiv类中显示其预览。
的HTML
<div id="dialog" title="Upload Your Profile Picture">
<form action="upload.php" method="post" enctype="multipart/form-data" target="upload_target" onsubmit="startUpload();" style="border1111111:1px solid yellow; margin-top:0px">
<p id="f1_upload_form" align="center"><!--<br/>-->
<label>
<br>File:
<input name="myfile" type="file" size="30" />
</label>
<label>
<input type="submit" name="submitBtn" class="sbtn" value="Upload" />
</label>
</p>
<p id="f1_upload_process">Loading...<br/><img src="img/loader.gif" /><!--<br/>--></p>
<iframe id="upload_target" name="upload_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe>
</form>
<div class="photo_upload_previews">
<div class="photo_upload_preview_indiv"></div><!-- end of class photo_upload_preview_indiv-->
</div><!--end of class photo_upload_previews -->
</div><!-- end of id dialog -->
的JavaScript
<script type="text/javascript">//<![CDATA[
$(document).ready(function () {
var dialog = $('#dialog');
dialog.dialog({
width:860,
height:560,
autoOpen: false
});
//dialog.dialog( "option", "10", 'top' );
$(".upload_photos").bind('click', function (e) {
e.preventDefault();
$("#f1_upload_process").css('display','none');
dialog.dialog('open');
});
});;//]]>
</script>
<script type="text/javascript">
function startUpload(){
$("#f1_upload_process").css('display','block');
document.getElementById('f1_upload_form').style.visibility = 'hidden';
//$(".prof_pic_up_instruct_text").css('display','none');
return true;
}
function stopUpload(success, arg2){
var result = '';
alert("success value ="+arg2);
if (success == 1) {
alert('file name ='+<?php echo $_SESSION['uploaded_file_name']; ?>);
$("#f1_upload_process").css('display','none');
document.getElementById('f1_upload_form').style.visibility = 'visible';
//$("#dialog").dialog('close');
$(".prof_pic_up_instruct_text").hide();
$("#f1_upload_process").hide();
//$(".photo_upload_preview_indiv:last").append('<div class="photo_upload_preview_indiv"><img src="src/"+arg2/></div>');
alert("0000000000000000");
}
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 + '<label>File: <input name="myfile" type="file" size="30" /><\/label><label><input type="submit" name="submitBtn" class="sbtn" value="Upload" /><\/label>';
document.getElementById('f1_upload_form').style.visibility = 'visible';
return true;
}
</script>
upload.php
<?php
session_start();
// Edit upload location here
$destination_path = getcwd().DIRECTORY_SEPARATOR;
$result = 0;
$target_path = $destination_path .'uploads/'.basename( $_FILES['myfile']['name']);
if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) {
$result = 1;
}
sleep(1);
$_SESSION['uploaded_file_name']=$_FILES['myfile']['name'].$_FILES["file"]["type"];
$uploaded_file_name=$_SESSION['uploaded_file_name'];
?>
<script language="javascript" type="text/javascript">
window.top.window.stopUpload('<?php echo $result; ?>' , '<?php echo $uploaded_file_name; ?>');
</script>
编辑:
meraj_63193201111201321808488_white.jpg是我尝试上传的文件。
这不是您的JS的第95行,而是包含内联JS的页面所生成的HTML的第95行。 上载文件的名称似乎引用不正确。 我确实在您当前的输出周围看到引号,但是我会仔细检查将什么输出发送到浏览器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.