get*_*way -1 javascript ajax jquery
有一个调试syntax错误,但我看不到它!我有点新手,所以请原谅我的代码!!
$(document).ready(function(){
/* fetch elements and stop form event */
$("form.follow-form").submit(function (e) {
/* stop event */
e.preventDefault();
/* "on request" */
$(this).find('i').addClass('active');
/* send ajax request */
$.ajax({
type: "POST",
url: "ajax_more.php",
data: $(this).serialize(),
cache: false,
success: function(html){
$("ul.statuses").append(html);
$("form.follow-form").remove();
}
});
else {
$(".morebox").html('The End');
}
return false;
});
});
Run Code Online (Sandbox Code Playgroud)
Pau*_*ite 10
你有一个else,但没有if.
这是带有一些适当缩进的代码 - 缩进使代码更容易理解,因此您可以更快地发现错误.
$(document).ready(function(){
/* fetch elements and stop form event */
$("form.follow-form").submit(function (e) {
/* stop event */
e.preventDefault();
/* "on request" */
$(this).find('i').addClass('active');
/* send ajax request */
$.ajax({
type: "POST",
url: "ajax_more.php",
data: $(this).serialize(),
cache: false,
success: function(html){
$("ul.statuses").append(html);
$("form.follow-form").remove();
}
});
======> /* HERE’S THE ELSE WITHOUT AN IF */
else {
$(".morebox").html('The End');
}
return false;
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
134 次 |
| 最近记录: |