How to retrieve Response from HTML and PHP pages
Hello all,
I am trying to invoke js code that submit parameter to php page , but the result
that the XMLHttpRequest Object captures is all the html of the page + the result from the php , Is I am wrong in this code?
Code:
var rqo;
function setReq(v) {
if (v != "") {
document.getElementById("result").innerHTML = "Fetching " + v;
rqo = new XMLHttpRequest();
var qs = encodeURIComponent(v);
var qry = "index.php?_data_input=" + qs;
rqo.open('GET',qry,true);
rqo.onreadystatechange = handleHttpResponse;
rqo.send(null);
return false;
}
}
function handleHttpResponse() {
var results = "";
qq (rqo.readyState == 4) {
results = rqo.responseText;
document.getElementById("result").innerHTML = results;
}
}
.....
....
<div class="c3" id="result">
</div>
....
<form method="get" name="_main_form" >
<input type="text"size="50" name="_data_input" id="_data_input">
<input type="button" value="Get Item" onclick="aboutlang(document._main_form._data_input.value)">
</form>
.....
Re: How to retrieve Response from HTML and PHP pages
If you don't want PHP to do something then you have to prevent it from doing that. Once it's printed the result you want you don't want it to continue, right? So don't let it continue.
Here's a hint: exit will stop execution dead in its tracks.
Re: How to retrieve Response from HTML and PHP pages
im not sure that technically its the right thing to do i just what using XMLHttprequest to catch the response from php the "<br> dddddddd </br>" string and innerHTML it to the result div but now its innerHTML all the page including the result to the result div.