Hello!

I'm using jQuery Form Plugin to upload files, and i discovered a
strange issue. If the response data contains jQuery code, a "$ is not
defined" javascript error occured, but the jquery code which produce
this error message, is executed. This only happens when file is
selected. If the file input is empty, everything is ok. Here is my
little test code: http://bogex.hu/jquery_upload.php

<?
header('Content-Type: text/html; charset=utf-8');
if (isset($_POST['feltolt'])) {?>
        <p>x</p>
        <p id="hely1"></p>
        <p id="hely2"></p>
        <script type="text/javascript">
        $('#hely1').html('<?=sha1(microtime())?>');
        $('#hely2').html('<?=sha1(microtime())?>');
        </script>
        <?exit;
}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<title>jQuery upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js";></script>
<script type="text/javascript"
src="http://malsup.com/jquery/form/jquery.form.js?2.28";></script>
<script type="text/javascript">
$(document).ready(function() {
        $('#ezaform').ajaxForm({
                target: $('#ide')
        });
});
</script>
</head>
<body>
<form id="ezaform" method="post" action="<?=$_SERVER['PHP_SELF']?>"
enctype="multipart/form-data">
<p><input type="file" name="cucc"/></p>
<p><input type="submit" name="feltolt" value="Upload!"/></p>
</form>
<div id="ide"></div>
</body>
</html>

Very interesting, if i used twice the jquery command, but the "$ is
not defined" error occurs only once. I mean the problem is in the
part, where Form Plugin uses an iframe to upload files, because only
occurs the problem if the file input not empty.

Anybody knows, how can i solve this problem?

Lay

Reply via email to