我有一个php页面,我会发送一个jquery ajax请求到另一个页面发送电子邮件。这个新页面接受一个参数,然后执行查询ecc ...
<div id="customer" name="customer" style="visibility: hidden;"><?php echo $customer; ?></div>
<?php echo '<input id="pulsante" type="image" src="includes/templates/theme485/buttons/english/button_confirm_order.gif" onclick="inoltra();"> '; ?>
这是脚本
function inoltra(){
var jqxhr = $.ajax({
type: "POST",
url: "../gestione_di_canio/services.php",
datatype: "json",
data: ??????????????
async:true,
success:function() {
try{
alert("ok");
}catch (e){
alert("correggi");
}
}
});
}
如何传递div“customer”的数据值?
答案 0 :(得分:0)
function inoltra(){
var jqxhr = $.ajax({
type: "POST",
url: "../gestione_di_canio/services.php",
datatype: "json",
data: JSON.stringify({paramName: $('#customer').html()}),
async:true,
success:function() {
try{
alert("ok");
}catch (e){
alert("correggi");
}
}
});
}
答案 1 :(得分:0)
function inoltra(){
var jqxhr = $.ajax({
type: "POST",
url: "../gestione_di_canio/services.php",
datatype: "json",
data: { customer: $('#customer').html() },
async:true,
success:function() {
try{
alert("ok");
}catch (e){
alert("correggi");
}
}
});
}
答案 2 :(得分:0)
在data: { varName: $('#customer').html() }
on Php:
$varName= $_POST['varName'];
对于更简单的sintax,你使用它(它是相同的):
$.post("../gestione_di_canio/services.php", { varName: $('#customer').html() } )
.success(function() {
try{
alert("ok");
}catch (e){
alert("correggi");
}
});
答案 3 :(得分:0)
我希望这对你有用......
function inoltra(){
({var jqxhr = $.ajax
type: "POST",
url: "../gestione_di_canio/services.php",
datatype: "json",
data: {"parameter1": value1, "parameter2": value2},// e.i data: {"customer": $('div#customer').html() },
async:true,
success:function() {
try{
alert("ok");
}
catch (e)
{
alert("correggi");
}
}
});
}
您想要发送的参数数量是可访问的。