Reputation: 11
I've a question about my code. How can I submit two values? I my code I submit only one string, but I don't know how I can submit tow values in the url.
I already tried cutting the submitted request-string
xmlhttp.open("GET", "<?php echo $actual_link; ?>/pages/panel/ajaxsearch.php?user=" + str + "secondvalue" + secondval, true);
// Cut
echo stristr($_REQUEST["user"], 'secondval');
It works, but it's ugly.
<script>
function showHint(str) {
if (str.length == 0) {
document.getElementById("txtHint").innerHTML = "";
return;
} else {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("txtHint").innerHTML = this.responseText;
}
}
xmlhttp.open("GET", "<?php echo $actual_link; ?>/pages/panel/ajaxsearch.php?user=" + str, true);
xmlhttp.send();
}
}
</script>
<input onkeyup="showHint(this.value)">
Upvotes: 1
Views: 41
Reputation: 4201
With & character
xmlhttp.open("GET","requesturl.php?Param=value¶m2=valie1¶m2=foo" , true);
If you have php array send to request with Ajax maybe want to a function ..php array convert to Ajax query
$data = array('cow' => 'milk', 'php' => 'hypertext processor');
echo http_build_query($data) ;
Output
cow=milk&php=hypertext+processor
Upvotes: 0
Reputation: 714
Use &
symbol for separation, like this
xmlhttp.open("GET", "<?php echo $actual_link; ?>/pages/panel/ajaxsearch.php?user=" + str + "&secondvalue" + secondval, true);
Upvotes: 1