안녕하세요, PHP, HTML 및 자바 스크립트/Ajax를 혼합 한 수업을위한 프로젝트가 있습니다.PHP에 대한 도움이 필요하고 "?"다음에 URL을 업데이트해야합니다.
요구 사항 중 하나는 "?"기호 다음에 N/V 쌍을 전달하는 서버에서 program.php를 실행하는 것입니다. " 어떻게해야합니까?
첫째로 .. 나는 NV 쌍이 무엇인지 모르며 우리가 읽은 링크가 그들에 대해 아무 말도하지 않는다. 나는 "Php nv pairs"를 봤는데 문자 그대로 친척이 없다.
나는 버튼을 클릭하면 url이 "?" 물론 동일한 코드가 더 이상이를 수행하지 않습니다.
// startgame function
// sart button pressed check fields, if OK send to PHP via get request
function startgame(){
//Create the XMLHttpRequest Object
var xmlhttp;
// error handling
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
http = xmlhttp;
// The PHP server script, called with N/V pair with GET request
// Using get request the NV pairs follow "?"
// execute program.php on server passing it the n/v pairs
// that follow the "?"
var url = "program.php?player1name=";
// for this example, only pass to PHP games played
// "&" separates n/v pairs
// player1name is name of algorithm player 1 is using
player1name = document.JForm.p1name.value;
player2name = document.JForm.p2name.value;
gamesplayed = document.JForm.gamesplayed.value;
sdata = url+player1name+"&gamesplayed="+gamesplayed;
// for a "real" solution, pass more data to PHP about state of game
// send get request to server with n/v pairs of screen data
http.open("GET",sdata, true);
// register with server what function to return data
http.onreadystatechange = handleHttpResponse;
// send request to server
http.send(null);
}
: 내 교수는 여기에
우리가 자신의 의견이 무엇을 설명하려고에 주어진 코드입니다 .. 아무것도 설명에서 끔찍한 심지어 완전하지 않은 자신의 오타 지침을 따르 우리 잎 아무거나는 도울 것이다, 감사합니다!
'GET'및 'POST'에 대한 정보를 읽으십시오. 저는 이것이 임무라는 것을 알고 있지만 JavaScript AJAX는 모든 브라우저가 약간 다르게 구현하기 때문에 쉽지 않습니다. jQuery의 AJAX를 사용하면 각 브라우저마다 AJAX 코드를 작성해야만합니다. – gwillie
@Dror, HansUp, user568109, andrewsi, Lego Stormtroopr. 여러분 모두가 명확하게 표현하는 3 줄을 읽지 못하기 때문입니다. 내 질문에,이 질문을 기다리게하는 것이 정말로 필요한가요? 이 질문은 제가 게시 한 지 5 분 후에 답변되었으므로 분명히 명확하게 지정되었습니다. 그러나 대답을 한 지 2 시간 만 기다렸습니다. 얼굴에 닿으면 명확한 특정 문제를 보는 법을 모르는 고마워요. 나는 더 이상 질문 할 수 없습니다. 답변을받은 후 2 시간 후에 명확하고 구체적인 문제를 신고 해 주셔서 감사합니다. – ModdedLife