alert("Your ID is"+randomString());
if ($('#txtAgree').is(':checked')) {
alert("You have succesfully submitted the form Thank You:");
var params = $("#payuForm").serialize();
$.ajax({
type: "POST",
url: "admin/api/process_pay.php",
data: params,
dataType: "json",
success: function(response) {
//alert("yes");
alert("Your ID is"+randomString());
refreshAdd();
}
});
} else {
alert("Please Select terms and conditions:");
return false;
}
// return true;
} catch (ex) {
alert("Error -> : " + ex.message);
}
});
function randomString() {
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
var string_length = 8;
var randomstring = '';
for (var i=0; i<string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum,rnum+1);
}
document.randform.randomfield.value = randomstring;
}
这里我通过警报调用javascript函数。 我想要每个表单提交的唯一键,并通过ajax调用执行表单。以上是我的代码。 在这里,我通过警报调用javascript函数。 我想要每个表单提交的唯一键,并通过ajax调用执行表单。以上是我的代码。
答案 0 :(得分:0)
function randomString() {
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
var string_length = 8;
var randomstring = '';
for (var i=0; i<string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum,rnum+1);
}
return randomstring; //was missing in your code
}
您没有从函数
返回randomstring