Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Wywoływanie funkcji php przez js.
Predator446
post
Post #1





Grupa: Zarejestrowani
Postów: 63
Pomógł: 0
Dołączył: 16.04.2006

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


Witam...
Jak zrobić by można było posługiwać się funkcjami napisanymi w php w kodzie js, tak jak jest to zrobione m.in. w xAjax?
Pozdrawiam.
Go to the top of the page
+Quote Post
tehn
post
Post #2





Grupa: Zarejestrowani
Postów: 63
Pomógł: 0
Dołączył: 8.09.2007

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


no właśnie tak jak jest to zrobione min w xAjaxie... smile.gif


--------------------
sidzina
Go to the top of the page
+Quote Post
qqrq
post
Post #3





Grupa: Zarejestrowani
Postów: 418
Pomógł: 8
Dołączył: 16.11.2006

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


Po to właśnie jest AJAX - wykonujesz spacerek na serwer bez przeładowania strony, gdzie znajduje się skrypt PHP z potrzebnymi ci funkcjami.


--------------------
Go to the top of the page
+Quote Post
callou
post
Post #4





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 19.09.2007

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


Masz tu prosty przykład
CODE
function createRequestObject() {
var ro;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject("Microsoft.XMLHTTP");
}else{
ro = new XMLHttpRequest();
}
return ro;
}

var http = createRequestObject();

function f_sndReq(action) {
http.open('POST', 'skrypt.php?szukaj='+action);
http.onreadystatechange = handleResponse;
http.send(null);
}

function f_hide(id){
document.getElementById(id).innerHTML = ""; // static
}

function handleResponse() {
if(http.readyState == 4){
var response = http.responseText;
// window.status="Proszę czekać...";
f_operacja(response);
// alert(response);
// document.getElementById('szukaj').value = response;
// document.getElementById('wd').innerHTML=response;
}
}

A potem masz inputa, który wywoluje AJAX
<input type="button" id="i_inp" value="Wyślij zapytanie" style="border:1px #000000 solid; font:10px; color:#000000; width:145px; height:25px; background-color:#e9f0f7;cursor:pointer; cursor:hand;" onclick="java script: f_sndReq(getElementById('szukaj').value);f_hide('i_wd');">

Ten post edytował callou 20.09.2007, 12:21:04
Go to the top of the page
+Quote Post
qqrq
post
Post #5





Grupa: Zarejestrowani
Postów: 418
Pomógł: 8
Dołączył: 16.11.2006

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


callou => Ten twój przykład - skądś go wziąłeś, czy sam pisałeś? Pytam, bo widzę kilka byków.


--------------------
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 21.08.2025 - 15:04