我想做的是使用ajax和php将图像显示为img标签。
我的问题是从emailName.php接收到图像的链接后,图像将不会显示。
我检查emailName.php,它将这个数组发送到ajax:
{"user_lname":"Oppa","user_code":"1","user_image":"myDocuments\/images\/default.jpg"}
显示的是user_lname和user_code,但没有显示图像。
我想在此标签上显示图像。
<img id="profileImage" name="profileImage" />
<label id="emailNameResult"></label>
<label id="emailCodeResult"></label>
脚本:
$(document).ready(function(){
var countTimerEmailName = setInterval(
function ()
{
emailName();
}, 500);
var $emailNameResult = $('#emailNameResult');
function emailName(){
$.ajax({
url:"emailName.php",
type:"GET",
data: { term : $('#email').val() },
dataType:"JSON",
success: function(result) {
$("#emailNameResult").html(result.user_lname);
$("#emailCodeResult").html(result.user_code);
$("#profileImage").html(result.user_image);
}
});
};
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句