2013-08-08 3 views
0

새 항목이 업데이트 된 후 피드가 자동으로 업데이트되는 피드 Facebook/twitter 스타일을 만들고 싶습니다. 지금까지, 나는이 했어 :아약스에서 성공 후 페이지를로드하는 방법

<form id="submitEvent"> 
<textarea placeholder="Suggest an event!"></textarea> 
<a class="button" id="newEvent" href="#">Submit</a> 
<script> 
$('#newEvent').click(function(e) { 
sugEvent = $('textarea').val(); 
user = $('#userName').text(); 
var data = "user=" + user + "&newEvent=" + sugEvent; 
$.ajax({ 
    data: data, 
    url:"uploadInfo.php", 
    success:function(result) 
    { 
     $("#otherSuggestedEvents").load(updateEvents.php); 
     $('#otherSuggestedEvents').show(); 
    } 
}); 
$('textarea').val(""); 
}); 
</script> 
<div id="otherSuggestedEvents"></div> 

updateEvents.php :

<?php 
$hostname= -censored-; 
$username=-censored-; 
$password=-censored-; 
$dbname=-censored-; 
$conn = mysqli_connect($hostname, $username, $password, $dbname); 
    $results = mysqli_query($conn, "SELECT * FROM `suggestedEvents` ORDER BY `time` DESC"); 
    while($row = mysqli_fetch_array($results)) 
    { 
     $username = $row['user']; 
     $event = $row['newEvents']; 
     echo "<div id='userEvents'>"; 

     echo "<p>$event</p>"; 
     echo "<h3>-$username</h3>"; 
     echo "</div>"; 
    } 
?> 

양식은 잘 데이터베이스를 업데이트 할 수 있지만 <div id="otherSuggestedEvents"></div>는 비어 있습니다. 무슨 일이 일어나고 있는지 잘 모르겠다. 어떤 도움을 주시면 감사하겠습니다! 이 유 도움이 될 것입니다 희망

$("#otherSuggestedEvents").load("updateEvents.php", function(response, status, xhr) { 
    if (status == "error") { 
    alert("error: " + xhr.status + " " + xhr.statusText); 
    } 
}); 

처럼 수표

+3

'.load ("/ updateEvents.php");로 시도하십시오. – Daniele

답변

0

시도 부하의 응답은()를 호출합니다.

관련 문제