简体   繁体   中英

jquery ' Uncaught ReferenceError not defined' error message in chrome console

Some error msg in chrome console and the expected result does not show up . can't make out what code segment produces it. SO FINDING NO OTHER WAY, I JUST PASTED THE CODE HERE

Console says :

Uncaught ReferenceError: meraj_63193201111201321808488_white is not defined

and the line number it gives is 95.

But at line number 95, I have:

alert("success value ="+arg2);

WHAT I WANT TO DO :

using jquery-ui , i used a dialog box for IMAGE FILE uploading. After the file gets uploaded I want to show a preview of it in photo_upload_preview_indiv class.

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>   

EDIT:

meraj_63193201111201321808488_white.jpg was the file I tried to upload.

This is not line 95 of your JS, but line 95 of the HTML generated by the page which contains inline JS. The name of the uploaded file appears to be quoted improperly. I do see quotes around the output you currently have, but I would double-check what output gets sent to the browser.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM