I'm making a bulletin board writing page.
If the user, writes board's subject and content and press write button, it goes to the server side and insert the data to the database. After that it relocates the page to the bulletin board list page. straight and forward and easy.
But the problem is the sync.
Sometime it relocates the page before the data has been inserted.
So the user has to refresh the page to update the view.
How can I show the page "after" the data has been inserted to the database?
This is the code
<title>Insert title here</title>
<base href="<?php echo base_url(); ?>" />
<link type="text/css" rel="stylesheet" href="formstyle.css">
<link type="text/css" rel="stylesheet" href="buttonstyle.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js">
</script>
<script type="text/javascript">
$(function(){
$("#writebutton").click(function(){
$.ajax({
type: 'POST',
url: "http://10.222.223.53/test1/index.php/home/writecomplete",
data: {
'subject': $("#subject").val(),
'content': $("#content").val()
},
success: function(msg){
location.href="http://10.222.223.53/test1";
}
});
});
});
</script>
</head>
<body>
<!-- UI Object -->
<fieldset>
<legend>
글쓰기 생성
</legend>
<div class="form_table">
<table border="1" cellspacing="0" summary="표의 요약을 반드시 넣어 주세요">
<tbody>
<tr>
<th scope="row">
제목
</th>
<td>
<div class="item">
<input type="text" style="width:320px" name="subject" title="레이블 텍스트" class="i_text" id="subject">
</div>
</td>
</tr>
<tr>
<th scope="row">
내용
</th>
<td>
<div class="item">
<textarea name="content" cols="50" rows="5" title="레이블 텍스트" class="i_text" id="content"></textarea>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<table>
<tr>
<td>
<span class="btn_pack medium" id="board_list"><a href="http://10.222.223.53/test1/index.php/home/gotolist">목록</a></span>
</td>
</tr>
<tr>
<td>
<span class="btn_pack medium" id="write_complete"><input type="submit" value="작성완료" id="writebutton"></span>
</td>
</tr>
</table>
</fieldset>
</body>
</html>