ここにアラート用の私のhtmlがあります
<div id="feature" class="feature">
<div id="alerts">
</div>
# other html data
</div>
これが私のAjax
電話です
// send the data to the server using .ajax() or .post()
$.ajax({
type: 'POST',
url: 'addVideo',
data: {
video_title: title,
playlist_name: playlist,
url: id,
success: notify('success', 'saved!')
error: notify('failure', 'not saved!')
},
notify
関数の外観は次のとおりです
function notify(notify_type, msg) {
var alerts = $('#alerts');
alerts.append('<a class="close" data-dismiss="alert" href="#">×</a>');
if (notify_type == 'success') {
alerts.addClass('alert alerts-success').fadeIn('fast');
}
if (notify_type == 'failure') {
alerts.addClass('alert alerts-error').fadeIn('fast');
}
}
私はここから参照を使用しています - http://twitter.github.com/bootstrap/components.html#alerts Firebugでデバッグすると、セレクターで要素が見つかりませんでした: "#alerts" divを見ることはできますがビューソースのタグ、何が間違っているのですか?
必要 - 応答に基づいて、テキストに適切なアラートを自動的に挿入したい
私はjQueryを学んでおり、これにはエラーがあると確信していますが、これがどこで失敗しているのか理解できません