Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> jak zmienić kod aby przekazywał 2 zmienne do pliku sprawdzającego, ajax / php
japolak
post
Post #1





Grupa: Zarejestrowani
Postów: 106
Pomógł: 0
Dołączył: 11.03.2007
Skąd: Łódzkie

Ostrzeżenie: (0%)
-----


witam
znalazlem na sieci fajny skrypt

  1. <script type="text/javascript">
  2. function toggle_username(userid) {
  3. if (window.XMLHttpRequest) {
  4. http = new XMLHttpRequest();
  5. } else if (window.ActiveXObject) {
  6. http = new ActiveXObject("Microsoft.XMLHTTP");
  7. }
  8. handle = document.getElementById(userid);
  9. var url = 'ajax.php?';
  10. if(handle.value.length > 0) {
  11. var fullurl = url + 'do=check_username_exists&username=' + encodeURIComponent(handle.value);
  12. http.open("GET", fullurl, true);
  13. http.send(null);
  14. http.onreadystatechange = statechange_username;
  15. }else{
  16. document.getElementById('username_exists').innerHTML = '';
  17. }
  18. }
  19.  
  20. function statechange_username() {
  21. if (http.readyState == 4) {
  22. var xmlObj = http.responseXML;
  23. var html = xmlObj.getElementsByTagName('result').item(0).firstChild.data;
  24. document.getElementById('username_exists').innerHTML = html;
  25. }
  26. }
  27. </script>
  28. <input id="username" type="text" name="username" onchange="toggle_username('username')" /><br />
  29. <div id="username_exists" style="font-size: 11px;font-weight: bold;color:#FF3300"> </div>


w danej chwili wysyla mi przez geta 1 zmienna username.
a chciałbym aby przesyłał 2 zmienne ( ta druga tylko jest potrzebna do warunku który chce postawić w z zapytaniu msyql, bez konieczności sprawdzania czy jest prawidłowa czy nie)


jak to zrobic??
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
esiek
post
Post #2





Grupa: Zarejestrowani
Postów: 65
Pomógł: 0
Dołączył: 6.11.2008
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


użyj w PHP

  1. $_POST['zmienna']


a jezeli chodzi o ajax to ja uzywam

  1. function rejestruj()
  2. {
  3. if(XMLHttpRequestObject){
  4. var div = document.getElementById("wynik");
  5. var przyciskEl = document.getElementById("rejestruj");
  6.  
  7. var reg_mail = document.getElementById("reg_mail").value;
  8. var reg_login = document.getElementById("reg_login").value;
  9. var reg_haslo = document.getElementById("reg_haslo").value;
  10. var reg_haslo2 = document.getElementById("reg_haslo2").value;
  11. var reg_regulamin = document.getElementById("reg_regulamin").value;
  12.  
  13.  
  14.  
  15.  
  16. reg_mail = escape(reg_mail);
  17. reg_login = escape(reg_login);
  18. reg_haslo = escape(reg_haslo);
  19. reg_haslo2 = escape(reg_haslo2);
  20. reg_regulamin = escape(reg_regulamin);
  21.  
  22.  
  23.  
  24. var str = "&reg_mail=" + reg_mail + "&reg_login=" + reg_login + "&reg_haslo=" + reg_haslo + "&reg_haslo2=" + reg_haslo2 + "&reg_regulamin=" + reg_regulamin;
  25.  
  26. przyciskEl.disabled = true;
  27. XMLHttpRequestObject.open("POST", "f/rejestruj.php");
  28. XMLHttpRequestObject.setRequestHeader(
  29. 'Content-Type', 'application/x-www-form-urlencoded');
  30.  
  31. XMLHttpRequestObject.onreadystatechange = function()
  32. {
  33. if (XMLHttpRequestObject.readyState == (1 || 0)){ div.innerHTML = "<center><img src='images/ajax.gif'></CENTER>";}
  34. if (XMLHttpRequestObject.readyState == 4){
  35. if(XMLHttpRequestObject.status == 200){
  36. var tekst = XMLHttpRequestObject.responseText;
  37. div.innerHTML = tekst;
  38. }
  39. przyciskEl.disabled = false;
  40. }
  41.  
  42. }
  43. XMLHttpRequestObject.send(str);
  44. }
  45. }
  46.  
  47. var XMLHttpRequestObject = getXMLHttpRequestObject();


jak chcesz uzyc moetody GET to mozesz zmienic tam w scryptcie ajaxu

Ten post edytował esiek 12.09.2009, 20:21:27
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: 3.10.2025 - 17:26