Jquery 无法使用ajax显示图像
我有一个输入文本字段,如果有人试图写入它,加载的图像就会出现。 我尝试了以下代码,但图像未显示在检查范围中Jquery 无法使用ajax显示图像,jquery,ajax,forms,Jquery,Ajax,Forms,我有一个输入文本字段,如果有人试图写入它,加载的图像就会出现。 我尝试了以下代码,但图像未显示在检查范围中 <html> <head> <title> Delivery Eligibility </title> </head> <body> <div> <form> Username:&
<html>
<head>
<title> Delivery Eligibility </title>
</head>
<body>
<div>
<form>
Username:<input type="text" autocomplete="off" name="user_name" id="user_id" class="user_name" >
<span class="check" ></span> <br/>
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(function()
{
$('.user_name').keyup(function()
{
$('.check').show();
$('.check').fadeIn(400).html('<img src="image/ajax-loading.gif" /> ');
}
}
</script>
</form>
</div>
</body>
</html>
分娩资格
用户名:
$(函数()
{
$('.user_name').keyup(函数()
{
$('.check').show();
$('.check').fadeIn(400.html('');
}
}
谁能告诉我哪里出了问题。事实上,您的结束标签错了:
$(function () {
$('.user_name').keyup(function () {
$('.check').show();
$('.check').fadeIn(400).html('<img src="image/ajax-loading.gif" /> ');
}); //<----check this
}); //<----and this
$(函数(){
$('.user_name').keyup(函数(){
$('.check').show();
$('.check').fadeIn(400.html('');
});//您的代码中有一个错误的结束标记
试试这个:
$(document).ready(function(){
$('.user_name').keyup(function () {
$('.check').show();
$('.check').fadeIn(400).html('<img src="image/ajax-loading.gif" /> ');
});
});
$(document).ready(function(){
$('.user_name').keyup(function(){
$('.check').show();
$('.check').fadeIn(400, function(){
$(this).html('<img src="image/ajax-loading.gif" /> ');
});
});
});
如果没有语法错误,它工作得很好:
$(函数()
{
$('.user_name').keyup(函数()
{
$('.check').show();
$('.check').fadeIn(400.html('');
});//你在这里漏掉了一个右括号
})这里呢
下次尝试使用您的控制台。信息非常明显:
未捕获的语法错误:意外标记}
缺少一些右括号。应为:
<html>
<head>
<title> Delivery Eligibility </title>
</head>
<body>
<div>
<form>
Username:<input type="text" autocomplete="off" name="user_name" id="user_id" class="user_name" >
<span class="check" ></span> <br/>
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(function()
{
$('.user_name').keyup(function()
{
$('.check').show();
$('.check').fadeIn(400).html('<img src="image/ajax-loading.gif" /> ');
})
});
</script>
</form>
</div>
</body>
</html>
分娩资格
用户名:
$(函数()
{
$('.user_name').keyup(函数()
{
$('.check').show();
$('.check').fadeIn(400.html('');
})
});
这是一个有效的演示:现在你应该有足够多的答案来说明同样的问题,从而理解你的错误!xD
$(function()
{
$('.user_name').keyup(function()
{
$('.check').show();
$('.check').fadeIn(400).html('<img src="http://placehold.it/16x16" /> ');
}); // you missed a closing parenthesis here
}); // and here
<html>
<head>
<title> Delivery Eligibility </title>
</head>
<body>
<div>
<form>
Username:<input type="text" autocomplete="off" name="user_name" id="user_id" class="user_name" >
<span class="check" ></span> <br/>
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(function()
{
$('.user_name').keyup(function()
{
$('.check').show();
$('.check').fadeIn(400).html('<img src="image/ajax-loading.gif" /> ');
})
});
</script>
</form>
</div>
</body>
</html>