发送带有参数的URL并在参数中使用javascript值

发送带有参数的URL并在参数中使用javascript值,javascript,php,ajax,Javascript,Php,Ajax,对于在线支付,我必须将参数发送到URL。在我的网站上,计算是用Javascript编写的,在线支付公司需要像MD5哈希这样的PHP参数 我尝试创建隐藏表单,并将所需的javascript值放入输入字段。成功了 我的隐藏形式: <form action="https://test.millikart.az:7444/gateway/payment/register" method="get" id="hiddenForm"> <input name="mid" value="un

对于在线支付,我必须将参数发送到URL。在我的网站上,计算是用Javascript编写的,在线支付公司需要像MD5哈希这样的PHP参数

我尝试创建隐藏表单,并将所需的javascript值放入输入字段。成功了

我的隐藏形式:

<form action="https://test.millikart.az:7444/gateway/payment/register" method="get" id="hiddenForm">
<input name="mid" value="unicopy" type="hidden">
<input name="amount" id="amount" value="" type="hidden">
<input name="currency" value="944" type="hidden">
<input name="description" value="" id="description" type="hidden">
<input name="reference" value="UNICSH3195319" type="hidden">
<input name="language" value="az" type="hidden">    
<input name="signature" value="<?php echo htmlspecialchars($signature); ?>" type="hidden">
<button type="button" class="btn btn-secondary" data-dismiss="modal" onClick="clearList()" >Reset</button>
<button  class="btn btn-primary" id="odenis" >Pay</button>
</form>

<script>
document.getElementById("amount").value= parseInt(yekunMeblegArray.reduce(myFunc));
document.getElementById("description").value= description;

//AJAX
$.ajax({
type: 'POST',
url: "index.php",
data: $("#hiddenForm").serialize(), 

success: function(response) { 
alert("succeed")},
});
</script>


我的猜测是:

1)
document.getElementById(“amount”).value=parseInt(yekunMeblegArray.reduce(myFunc))未设置正确的值(您可以使用设置的值下面的
console.log
语句进行调试)

2)
$(“#hiddenForm”).serialize()
此函数调用不会以您认为的方式生成数据。您应该
console.log
进行调查

我建议您在以下内容中查看
ajax
对象的
contentType
dataType
属性:


ajax在哪里?@mplungjan编辑了我的问题并添加了AJAXI。我也尝试使用ajax只发送两个值(数量和描述),但仍然无法成功。您没有使用ajax响应执行任何操作,并且没有错误函数来查看它是否失败。您是否检查了调用的响应?如果您得到的响应没有错误,请尝试使用var_dump($_POST)查看值是否已传递到服务器端。第一点起作用,因为我在发送时在URL中看到正确的金额值,并且我更改了
$(“#hiddenForm”)。将
序列化为
“amount=“+amount
”要查看此行中是否存在问题,仍然获取数组(0)当var_转储($_POST)时
<?php 

  $mid="unicopy";
  $amount=$_POST['amount'];
  $currency="944";
  $description=$_POST['desc'];
  $reference="UNICSH3195319";
  $language="az";
  $key="123456qwerty";

  $signature=strtoupper(md5(strlen($mid).$mid.strlen($amount).$amount.strlen($currency).$currency.(!empty($description)? strlen($description).$description :"0").strlen($reference).$reference.strlen($language).$language.$key));

  ?>