使用jquery ajax发送参数

发布于 2024-12-05 22:41:43 字数 822 浏览 0 评论 0原文

我有一个 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();">&nbsp; &nbsp;'; ?>

这是脚本,

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”的数据值?

I've a php page and I would to send a jquery ajax request to another page for sending email. This new page accept one parameter and then it executes query 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();">   '; ?>

this is the script

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");
                } 
        }
});
}

how can I pass to data value of div "customer"?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

甜中书 2024-12-12 22:41:43

上的 data: { varName: $('#customer').html() }

在Php

$varName= $_POST['varName'];

上:为了更简单的语法,您可以使用这个(它是相同的):

$.post("../gestione_di_canio/services.php", { varName: $('#customer').html() } )
.success(function() { 
    try{
        alert("ok");

    }catch (e){
        alert("correggi");
    } 
});

On data: { varName: $('#customer').html() }

on Php:

$varName= $_POST['varName'];

For a simpler sintax, you use this (it the same):

$.post("../gestione_di_canio/services.php", { varName: $('#customer').html() } )
.success(function() { 
    try{
        alert("ok");

    }catch (e){
        alert("correggi");
    } 
});
欢你一世 2024-12-12 22:41:43
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");
                    } 
            }
    });
}
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");
                    } 
            }
    });
}
鹿! 2024-12-12 22:41:43

我希望这对您有用...

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");
         } 
    }
});

}

因为您想要发送的许多参数都可以访问。

I hope this will work for ya...

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");
         } 
    }
});

}

as many parameters you want to send would be accessable.

兔姬 2024-12-12 22:41:43
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");
                } 
        }
});
}
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");
                } 
        }
});
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文