当我单击按钮时,它会将我重定向到removeadmin.php?userid = undefined。我的预期结果是例如removeadmin.php?userid = 0001,具体取决于该人按下了哪个按钮。我试图更改为window.location =“ removeadmin.php?userid =” + arr [i] .userid。但是,似乎没有任何作用。
(function () {
$(document).ready(function () {
showadmin();
});
function showadmin() {
var url = serverURL() + "/showadmin.php";
var userid = "userid";
var employeename = "employeename";
var role ="role";
var JSONObject = {
"userid": userid,
"employeename": employeename,
"role": role
};
var myJSON = JSON.stringify(JSONObject);
$.ajax({
url: url,
type: 'POST',
data: JSONObject,
dataType: 'json',
contentType: "application/json; charset=utf-8",
success: function (arr) {
_getAdminResult(arr);
},
error: function () {
alert("fail");
}
});
}
function _getAdminResult(arr) {
var gridcontainers = [];
for (var i = 0; i < arr.length; i++) {
var gridcontainer = $("<div />").addClass("grid-container");
gridcontainer.append($("<div />").text(arr[i].userid));
gridcontainer.append($("<div />").text(arr[i].employeename));
gridcontainer.append($("<div />").text(arr[i].role));
gridcontainer.append($("<div />").append(
$("<button />")
.on("click", BtnRemoveAdmin)
.text("Remove")
));
gridcontainers.push(gridcontainer);
}
$("#name").append(gridcontainers);
}
function BtnRemoveAdmin(event) {
var data = event.data;
removeadmin(event.data);
}
function removeadmin(userid) {
window.location = "removeadmin.php?userid=" + userid;
}
})();
答案 0 :(得分:1)
仅<?php
$X = new X ([
'Card' => '53535',
'Terminal' => '43534534',
'Amount' => '1000',
'OrderId' => '1',
'ReturnUrl' => 'test url',
'Password' => 'D414305754BE7625CA70D',
'MobileNo' => '03003030',
'AdditionalData' => 'test' ]);
$request_key = $X ->request(2, 1000, 'http://');
class WebServicePaymentRequest
{
public $Card = "53535";
public $Terminal = "43534534";
public $Amount = "1000";
public $OrderId = "1";
public $ReturnUrl = "test url";
public $Password = "D414305754BE7625CA70D";
public $MobileNo = "03003030";
}
class X {
private $Card;
private $Terminal;
private $Amount;
private $OrderId;
private $ReturnUrl;
private $Password;
private $MobileNo;
private $AdditionalData;
private $Token;
private $wsdl_url = 'https://XXX/WebServices/PaymentUtils.svc?wsdl';
public function __construct($params)
{
$this->Card = $params['Card'];
$this->Terminal = $params['Terminal'];
$this->Password = $params['Password'];
$this->Amount = $params['Amount'];
$this->OrderId = $params['OrderId'];
$this->ReturnUrl = $params['ReturnUrl'];
$this->MobileNo = $params['MobileNo'];
$this->AdditionalData = $params['AdditionalData'];
}
public function request($order_id, $amount, $callback)
{
$options = array(
"soap_version" => SOAP_1_2,
"cache_wsdl" => WSDL_CACHE_NONE,
"exceptions" => false,
"encoding"=> 'UTF-8'
);
$client = new SoapClient($this->wsdl_url, $options);
$obj = new WebServicePaymentRequest;
$obj->Amount = $amount; // Output the property
$obj->OrderId = $order_id;
$obj->ReturnUrl = $callback;
$result = $client->PaymentRequest($obj);
echo $result;
var_dump($result);
$result = json_decode($result, true);
$this->Token = $result['Token'];
}
}
?>
未定义。以此更改event.data
和_getAdminResult
函数
BtnRemoveAdmin