私はソーシャルグループの壁を管理しており、ページをリフレッシュせずにグループウォールをダイナミックにするための解決策を見つけようとしています。テキストエリアがあり、ポストボタンをクリックしたいとき。データはデータベースに保存されていると私はすでにそれを投稿したテキストを検索したいページさわやかにされています。ここではjQueryでイベントの後にdbに格納して新しいdivに結果を追加するにはどうすればいいですか?
をスクリプトです:
<script>
$(document).ready(function() {
$("#btnpost").click(function() {
$("#publication").prepend('<div class="panel panel-success rounded shadow" style="text-align: left;margin-bottom: 5px;">' +
'<div class="panel-heading no-border">'+
'<div class="pull-left half">'+
'<div class="media" style="text-align: left;">'+
'<div class="media-object pull-left" style="margin-top: 35px;">'+
'<img src="http://bootdey.com/img/Content/avatar/avatar2.png" style="width: 40px;height: 40px;">' +
'</div>'+
'</div>'+
'</div>'+
'<a href="">test profile</a>'+
'<span class="text-white h6" style="display: block; color: black;">on 8th June, 2014</span>'+
'<br>'+
'<span style="color: black;margin-bottom: 10px;word-break: break-all ">#wonderful place man congratulationhh </span>'+
'</div>'+
'</div>'+
'<div class="panel-footer">'+
'<form action="#" class="form-horizontal">'+
'<div class="form-group has-feedback no-margin">'+
'<input class="form-control" type="text" placeholder="Votre commentaire ici..." style="width: 95%;margin-left: 10px;">'+
'</div>'+
'</form>'+
'</div>');
});
});
</script>
私は、データが格納されて作ることができる方法を見つけたいですそのdiv要素で、ここですべてのコードを見ずに
AJAXを使用してサーバーにデータを送信します。 – Barmar
データを保存した後、すべて更新した後にビューが更新されるようになりました。 –
情報をデータベースに保存しました。ページをリロードすると、データベースから情報を取得してページを再作成します。 – Barmar