【发布时间】:2014-04-24 14:27:18
【问题描述】:
<div class="RegisterFrame">
<form method="post" id="form" action="registeration.php" class="reg" enctype="multipart/form-data">
<input type="file" class="fileChooser" name="img">
<div class="uploadimg" name="imgUploader"><img src="" name='IDpic' class="IDpic"></div><br>
<text>Username</text><input type="text" class="textBox" name="user"><br>
<text>Password</text><input type="password" class="textBox" name="pass"><br>
<text>re-enter your password</text><input type="password" class="textBox" name="repass"><br>
<text>e-mail</text><input type="text" class="textBox" name="email"><br>
<text>re-enter your e-mail</text><input type="text" class="textBox" name="reemail"><br>
<button class="Con" type="submit">Done O.o</button><button class="Res" type="button">reset</button>
</form>
</div>
============================================
脚本代码:
$("#form").submit(function(e) {
e.preventDefault();
// alert('test');
data = new FormData($('#form')[0]);
// console.log('Submitting');
$.ajax({
type: 'POST',
url: 'registeration.php',
data: data,
cache: false,
contentType: false,
processData: false,
success: function(result) {
alert(result);
//PS: the result gives the correct full path yet the image doesn't change
document.getElementsByClassName('.IDpic').src=result;
}
});
});
【问题讨论】:
-
编辑您的问题。解释问题是什么(在代码块格式之外)。你写“用户名”、“密码”等,但你没有解释它是什么。很难阅读您的问题。根据您的“P.S.”,您的问题是“结果给出了正确的完整路径,但图像没有改变。”问题不应隐藏在代码中。
-
问题是什么?
-
为什么是 document.getElementsByClassName('.IDpic').src=result;不工作
-
错误出现在路径中...... C:\wamp\www\playAround\uploads 是给定的路径,它应该只是“\uploads”:)
标签: javascript jquery html ajax