我正在尝试使用xmlhttp检索表单内容,但它不会在下一页上发布任何内容。
如果我在使用我的脚本的页面中使用该表单,它会发布但不会发送请求检索到的信息,并且整个表单都不起作用。
html页面(php)是xhr.php我无法找到任何相关项目
var refreshDelay = 10000;
/* Creates the XMLHTTPRequest object depending on the browser */
function createRequestObject() {
var ro;
if(navigator.appName == "Microsoft Internet Explorer"){
ro = new ActiveXObject("Microsoft.XMLHTTP");
}else{
ro = new XMLHttpRequest();
}
return ro;
}
var http = createRequestObject();
/* Makes the request back to /div.php ... change the URL to whatever
script you put on the server side to return the contents of the div only */
function sndReq() {
http.open('get', '/xhr.php?UI=<?php echo $_SESSION['GLOBALID']; ?>&perpage=<?php echo $perpage; ?>&webshop=all ');
http.onreadystatechange = handleResponse;
http.send();
}
/* Does the work of replacing the contents of the div id="target" when
the XMLHTTPRequest is received, and schedules next update */
function handleResponse() {
if(http.readyState == 4 && http.status == 200){
var response = http.responseText;
document.getElementById('NewOrderstable').innerHTML = response;
}
}
/* Schedules the first request back to the server. Subsequent refreshes
are scheduled in handleResponse() */
setTimeout(sndReq, 1);
&#13;
<?php
session_start();
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(E_ALL);
include 'includes/navigator.php';
?>
<div class="content-panel">
<table class="table table-striped table-advance table-hover">
<div class="col-md-2">
<h4><i class="fa fa-angle-right"></i> Alle Orders</h4>
</div>
<div class="col-md-2 text-right">
<form method='post' action=<?php NavigationPage($webshops,$page,$perpage); ?>>
<label>per pagina</label>
<input type="number" name="perpage" value=<?php echo "'$perpage'"; ?> min="1" max="100">
<button type="submit" class="btn btn-theme">wijzigen</button>
</form>
</div>
<div class="col-md-5">
</div>
<div class="col-md-2">
<form method="post" action="actionhandler/handler.php">
<select class="form-control" name="action">
<option value="-1">Bulk Actions</option>
<option value="trash">Move to Trash</option>
<option value="mark_processing">Mark processing</option>
<option value="mark_on-hold">Mark on-hold</option>
<option value="mark_completed">Mark complete</option>
<option value="wcmp_export">MyParcel: Export</option>
<option value="wcmp_print">MyParcel: Print</option>
<option value="wcmp_export_print">MyParcel: Export & Print</option>
<option value="pdf">factuur</option>
</select>
</div>
<div class="col-md-1">
<button type="submit" name="source" value="<?php echo "NewOrders.php?webshop=$webshops" ?>" class="btn btn-theme">toepassen</button>
</div>
<thead>
<tr>
<th><input type="checkbox" onclick="toggle(this)"/></th>
<th><i class="fa fa-desktop"></i> Webshop</th>
<th><i class="fa fa-bullhorn"></i> ID</th>
<th class="hidden-phone"><i class="fa fa-question-circle"></i> Datum</th>
<th><i class="fa fa-bookmark"></i> Status</th>
<th><i class=" fa fa-edit"></i> acties</th>
</tr>
</thead>
<tbody >
<?php
$_SESSION['GLOBALID'] = $_GET['UI'];
$perpage = $_GET['perpage'];
include 'client.php';
$requested = ClientLoader("all");
$AllOrders = OpenOrders($requested, "processing",$perpage);
usort($AllOrders, 'arraysorter');
$result = 0;
foreach ($AllOrders as $order) {
echo "<tr>
<td><input type='checkbox' name='SelectOrder[]' value='" . $order['webshop'] . "|" . $order['Orderid'] . "'/></td>
<td> <a href='" . $order['wpadmin'] . "'>" . $order['webshop'] . "</a></td>
<td>" . $order['Orderid'] . "</td>
<td>" . $order['date'] . "</td>
<td><span class='label label-success label-mini'>" . $order['status'] . "</span></td>
<td>
<select name='type[]'class='form-control'>
<option value='1'>pakket</option>
<option value='2'>brief</option>
<option value='3'>ongefr</option>
</select>
</td></tr>";
$result++;
}
if($result == 0){
echo "<tr><td align='center' colspan='6'>niks te zien hier <a href='?webshop=" . $webshops . "&page=1&perpage=" . $perpage . "'>ga terug naar pagina 1</a></td></tr>";
}
?>
</tbody>
</table>
</form>
</div><!-- /content-panel -->
&#13;
这是它输出的内容
<div class="content-panel">
<div class="col-md-2">
<h4><i class="fa fa-angle-right"></i> Alle Orders</h4>
</div><div class="col-md-2 text-right">
<form method="post" action="?webshop=all&page=1&perpage=50"></form>
<label>per pagina</label>
<input type="number" name="perpage" value="50" min="1" max="100">
<button type="submit" class="btn btn-theme">wijzigen</button>
</div><div class="col-md-5">
</div><div class="col-md-2">
<form method="post" action="actionhandler/handler.php"></form>
<select class="form-control" name="action">
<option value="-1">Bulk Actions</option>
<option value="trash">Move to Trash</option>
<option value="mark_processing">Mark processing</option>
<option value="mark_on-hold">Mark on-hold</option>
<option value="mark_completed">Mark complete</option>
<option value="wcmp_export">MyParcel: Export</option>
<option value="wcmp_print">MyParcel: Print</option>
<option value="wcmp_export_print">MyParcel: Export & Print</option>
<option value="pdf">factuur</option>
</select>
</div><div class="col-md-1">
<button type="submit" name="source" value="NewOrders.php?webshop=all" class="btn btn-theme">toepassen</button>
</div><table class="table table-striped table-advance table-hover">
<thead>
<tr>
<th><input type="checkbox" onclick="toggle(this)"></th>
<th><i class="fa fa-desktop"></i> Webshop</th>
<th><i class="fa fa-bullhorn"></i> ID</th>
<th class="hidden-phone"><i class="fa fa-question-circle"></i> Datum</th>
<th><i class="fa fa-bookmark"></i> Status</th>
<th><i class=" fa fa-edit"></i> acties</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox" name="SelectOrder[]" value="https://example.com/|13513"></td>
<td> <a href="#">https://example.com/</a></td>
<td>13513</td>
<td>2018-04-24T07:21:35</td>
<td><span class="label label-success label-mini">processing</span></td>
<td>
<select name="type[]" class="form-control">
<option value="1">pakket</option>
<option value="2">brief</option>
<option value="3">ongefr</option>
</select>
</td></tr><tr>
<td><input type="checkbox" name="SelectOrder[]" value="https://example.com/|13512"></td>
<td> <a href="#">https://example.com/</a></td>
<td>13512</td>
<td>2018-04-24T07:10:19</td>
<td><span class="label label-success label-mini">processing</span></td>
<td>
<select name="type[]" class="form-control">
<option value="1">pakket</option>
<option value="2">brief</option>
<option value="3">ongefr</option>
</select>
</td></tr><tr>
<td><input type="checkbox" name="SelectOrder[]" value="https://example.com/|13510"></td>
<td> <a href="#">https://example.com/</a></td>
<td>13510</td>
<td>2018-04-23T20:15:59</td>
<td><span class="label label-success label-mini">processing</span></td>
<td>
<select name="type[]" class="form-control">
<option value="1">pakket</option>
<option value="2">brief</option>
<option value="3">ongefr</option>
</select>
</td></tr><tr>
<td><input type="checkbox" name="SelectOrder[]" value="https://example.com/|13509"></td>
<td> <a href="#">https://example.com/</a></td>
<td>13509</td>
<td>2018-04-23T19:25:43</td>
<td><span class="label label-success label-mini">processing</span></td>
<td>
<select name="type[]" class="form-control">
<option value="1">pakket</option>
<option value="2">brief</option>
<option value="3">ongefr</option>
</select>
</td></tr><tr>
<td><input type="checkbox" name="SelectOrder[]" value="https://example.com/|13508"></td>
<td> <a href="#">https://example.com/</a></td>
<td>13508</td>
<td>2018-04-23T18:56:53</td>
<td><span class="label label-success label-mini">processing</span></td>
<td>
<select name="type[]" class="form-control">
<option value="1">pakket</option>
<option value="2">brief</option>
<option value="3">ongefr</option>
</select>
</td></tr><tr>
<td><input type="checkbox" name="SelectOrder[]" value="https://example.com/|13507"></td>
<td> <a href="#">https://example.com/</a></td>
<td>13507</td>
<td>2018-04-23T16:28:15</td>
<td><span class="label label-success label-mini">processing</span></td>
<td>
<select name="type[]" class="form-control">
<option value="1">pakket</option>
<option value="2">brief</option>
<option value="3">ongefr</option>
</select>
</td></tr><tr>
<td><input type="checkbox" name="SelectOrder[]" value="https://example.com/|13506"></td>
<td> <a href="#">https://example.com/</a></td>
<td>13506</td>
<td>2018-04-23T15:47:33</td>
<td><span class="label label-success label-mini">processing</span></td>
<td>
<select name="type[]" class="form-control">
<option value="1">pakket</option>
<option value="2">brief</option>
<option value="3">ongefr</option>
</select>
</td></tr><tr>
<td><input type="checkbox" name="SelectOrder[]" value="https://example.com/|13505"></td>
<td> <a href="#">https://example.com/</a></td>
<td>13505</td>
<td>2018-04-23T15:25:12</td>
<td><span class="label label-success label-mini">processing</span></td>
<td>
<select name="type[]" class="form-control">
<option value="1">pakket</option>
<option value="2">brief</option>
<option value="3">ongefr</option>
</select>
</td></tr><tr>
<td><input type="checkbox" name="SelectOrder[]" value="https://example.com/|8473"></td>
<td> <a href="#">https://example.com/</a></td>
<td>8473</td>
<td>2018-04-23T14:48:17</td>
<td><span class="label label-success label-mini">processing</span></td>
<td>
<select name="type[]" class="form-control">
<option value="1">pakket</option>
<option value="2">brief</option>
<option value="3">ongefr</option>
</select>
</td></tr><tr>
<td><input type="checkbox" name="SelectOrder[]" value="https://example.com/|13503"></td>
<td> <a href="#">https://example.com/</a></td>
<td>13503</td>
<td>2018-04-23T14:23:02</td>
<td><span class="label label-success label-mini">processing</span></td>
<td>
<select name="type[]" class="form-control">
<option value="1">pakket</option>
<option value="2">brief</option>
<option value="3">ongefr</option>
</select>
</td></tr><tr>
<td><input type="checkbox" name="SelectOrder[]" value="https://example.com/|13440"></td>
<td> <a href="#">https://example.com/</a></td>
<td>13440</td>
<td>2018-04-15T09:38:48</td>
<td><span class="label label-success label-mini">processing</span></td>
<td>
<select name="type[]" class="form-control">
<option value="1">pakket</option>
<option value="2">brief</option>
<option value="3">ongefr</option>
</select>
</td></tr> </tbody>
</table>
</div>
&#13;
答案 0 :(得分:0)
使用encodeURIComponent
对网址进行编码。
对XMLHttpRequest
{
let xhr = new XMLHttpRequest();
let url = "/xhr.php?" + encodeURIComponent( `UI=<?php echo $_SESSION['GLOBALID']; ?>&perpage=<?php echo $perpage; ?>&webshop=all` );
xhr.open( "GET", url, true );
xhr.addEventListener( "load", function ( event ) {
document.querySelector( "#NewOrderstable" ).innerHTML = xhr.response;
} );
xhr.send();
}
&#13;