私はいくつかのチュートリアルを行ったが、私が継承したコードはおそらく高度です。 このコードを理解するのに役立つものがありますか、それを私に説明してください。私が知っているすべては、私が更新するとき/気分descと色を変え、私は変化の色で入力した気分descと色の実際の文言...いくつかの助けajaxコードを理解してください
function ax_update_mood()
{
//what is it doing here?
var str_mood_desc = $('#moodmeter_form_mood_desc').val();
var str_mood_color = $('#moodmeter_form_mood_color').val();
//understand this part
if(str_mood_desc.length < 3 || str_mood_desc.length > 32)
{
alert('Mood Description must be between 3 - 32 characters long.');
return
}
//understand this part
if(str_mood_color.length < 1 || str_mood_color.length > 32)
{
alert('Mood Color must be between 3 - 32 characters long.');
return
}
//have NO idea on what is going on here!
$.ajax({
type: "POST",
url: "moodupdate",
data: "mood_desc="+str_mood_desc+"&mood_color="+str_mood_color,
success: function(msg)
{
ax_get_mood();
alert("Mood Updated");
}
})
}
function ax_get_mood()
{
//this is also a complete mistery, have no idea what this code does
$.getJSON('/apps.php/profile/getmood', function(data)
{
//const TIME_DIFF = 180;
var td_mood_color = $('#current_mood_color');
var td_mood_desc = $('#current_mood_desc');
var spn_mood_updated_at = $('#spn_updated_at');
if(data.date_diff_in_min < 180)
{
spn_mood_updated_at.removeClass().addClass('span_mood_red');
td_mood_desc.removeClass().addClass('span_mood_red');
td_mood_color.removeClass().addClass('span_mood_red');
}
else
{ spn_mood_updated_at.removeClass().addClass('span_mood_blue');
td_mood_desc.removeClass().addClass('span_mood_blue');
td_mood_color.removeClass().addClass('span_mood_blue');
}
spn_mood_updated_at.text(data.mood_updated_at);
td_mood_color.text(data.mood_color);
td_mood_desc.text(data.mood_desc);
});
}
公式であなたに
ありがとうございました! –