我使用jquery.form.js到AJAX提交表單並獲取響應更新成功圖片src。如何使用jquery.form.js
我的PHP頁面被設置爲回波圖像的URL像 「圖像/拇指/ 071112130957.jpg」
繼承人我的jquery:
$("#imageform").ajaxForm(
{
target: '#preview'
}).submit();
});
我的繼承人HTML表單
<form action="cropscript.php" id="imageform" method="post" enctype="multipart/form-data">
<input type="file" name="image" id="image" /> <br/>
<input type="submit" name="submit" value="upload image" />
</form>
<div id="preview" > </div>
<img src = "thumbs/default.jpg" id="thumb_img" />
現在我的問題是如何在ajaxform成功後更新img#thumb_img src?
它不工作。我如何生成response.imgsrc?我做了數據類型:json和echo json_encode($ imgsrc),是嗎? – jinni
我的JSON是outputing:{ 「IMGSRC」: 「071112161921.jpg」}如何使用jQuery怎麼做呢? – jinni
如果數據是JSON,您可以使用,如果沒有把握控制檯日誌響應數據 $( '#thumb_img')ATTR( 'SRC', '文件夾/路徑/' + response.imgsrc)。 – Kotzilla