Я новичок в ajax и jQuery, я только что сделал это для своего последнего проекта года
У меня есть некоторые проблемы при добавлении методов в сценарий Java, это мой сценарий AJAX:
$(document).ready(function() {
$('#campus_feed').html('<br><br><br><br><br><br><br><br><br><br><br><br>
<center><img src="loader.gif"></center>');
fetch_data();
setInterval(fetch_data, 5000); // 5 seconds
// FETCHING DATA
function fetch_data()
{
var action = "fetch";
$.ajax({
url:"fetch_action.php",
method:"POST",
data:{action:action},
success:function(data)
{
$('#campus_feed').html(data);
}
})
}
/////////////////////////////////////////////////////
$("#profile_nav").click(function profile_dflt() {
$('#content').html('<br><br><br><br><br><br><br><br><br><br><br><br><img src="loader.gif">');
$.ajax({
url: "profile.php",
method:"POST",
success: function(result)
{
$("#profile_nav").css({"background-color":"#4CAF50"});
$("#nofication_nav").removeAttr("style");
$("#chat_nav").removeAttr("style");
$("#forum_nav").removeAttr("style");
$("#post_nav").removeAttr("style");
$("#content").html(result);
}
});
});
////////////////////////////////////////////////////////////
$("#nofication_nav").click(function(){
$.ajax({
url: "nofication.php",
method:"POST",
success: function(result)
{
$("#nofication_nav").css({"background-color":"#CCCC00"});
$("#profile_nav").removeAttr("style");
$("#chat_nav").removeAttr("style");
$("#forum_nav").removeAttr("style");
$("#post_nav").removeAttr("style");
$("#content").html(result);
}
});
});
///////////////////////////////////////////////////////////
$("#chat_nav").click(function(){
$.ajax({
url: "chat.php",
method:"POST",
success: function(result)
{
$("#chat_nav").css({"background-color":"#008CBA"});
$("#nofication_nav").removeAttr("style");
$("#profile_nav").removeAttr("style");
$("#forum_nav").removeAttr("style");
$("#post_nav").removeAttr("style");
$("#content").html(result);
}
});
});
///////////////////////////////////////////////////////
$("#forum_nav").click(function(){
$.ajax({
url: "forum.php",
method:"POST",
success: function(result)
{
$("#forum_nav").css({"background-color":"#FF00FF"});
$("#nofication_nav").removeAttr("style");
$("#chat_nav").removeAttr("style");
$("#profile_nav").removeAttr("style");
$("#post_nav").removeAttr("style");
$("#content").html(result);
}
});
});
///////////////////////////////////////////////////////
$("#post_nav").click(function(){
$.ajax({
url: "post.php",
method:"POST",
success: function(result)
{
$("#post_nav").css({"background-color":"#F44336"});
$("#nofication_nav").removeAttr("style");
$("#chat_nav").removeAttr("style");
$("#forum_nav").removeAttr("style");
$("#profile_nav").removeAttr("style");
$("#content").html(result);
}
});
});
});
Когда я добавляю метод SETINTERVAL()
и другие дополнительные методы, он показывает мне предупреждающее сообщение, я не знаю, почему отображается это предупреждение, я думаю, что я допустил ошибку в объявлении синтаксиса, пожалуйста, помогите мне решить эту проблему