Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [AJAX][PHP]Przesyłanie $_POST poprzez jquery
Konop857
post
Post #1





Grupa: Zarejestrowani
Postów: 81
Pomógł: 2
Dołączył: 4.05.2011

Ostrzeżenie: (10%)
X----


Witam, mam taki kawałek kodu :
  1. <script type='text/javascript'>
  2. function send_message(){
  3. var ajax_method = typeof XMLHttpRequest == 'undefined'?new ActiveXObject('Microsoft.XMLHttp'):new XMLHttpRequest();
  4. ajax_method.onreadystatechange=function(){
  5. if (ajax_method.readyState==4 && ajax_method.status==200){
  6. document.getElementById('txtHint').innerHTML=ajax_method.responseText;
  7. }
  8. }
  9. ajax_method.open('POST','?subtopic=chat_actions&action=send_message', true);
  10. ajax_method.send();
  11. };
  12. </script>
  13. <center>Chat
  14. <form action='java script: void(0)' type='post'>
  15. <table width='100%' cellspacing='1' cellpadding='1'>
  16. <tr>
  17. <td width='30%' class='table_int'>Kanał</td>
  18. <td width='70%' class='table_int'>essia</td>
  19. </tr>
  20. <tr>
  21. <td width='30%' class='table_nint'><input type='text' name='chat_message' size='30'/></td>
  22. <td width='70%' class='table_nint'><input type='submit' value='Wyślij' onclick='send_message()'/></td>
  23. </tr>
  24. </table>
  25. </form>

  1. $query = $SQL->prepare("INSERT INTO chat_messages(`id`, `chat_id`, `message_person`, `message_date`, `message_text`)
  2. VALUES('0', '1', :sender, :datetime, :message)");
  3. $query->bindValue(':sender', $username, PDO::PARAM_STR);
  4. $query->bindValue(':datetime', date('Y-m-d H:i:s'), PDO::PARAM_STR);
  5. $query->bindValue(':message', $_POST['chat_message'], PDO::PARAM_STR);
  6. $query->execute();

Niestety, zapytanie się nie wykonuje, gdyż zmienna $_POST jest pusta.
Mógłby mi ktoś podpowiedzieć co robię źle (IMG:style_emoticons/default/smile.gif) ?

Pozdrawiam
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 4.10.2025 - 16:38