0

我在这里遇到了一个问题,我觉得我错过了一些东西,但我无法解决它。

我有以下内容:

function success(){
    alert("success");   
}
function failure(){
    alert("failure");   
}

function sendData(){
    var userName = $("#contact-name-data").val();
    var userPhone = $("#contact-phone-data").val();
    var userEmail = $("#contact-email-data").val();
    var userQuery = $("#contact-enquiry-data option:selected").text();

    var request = $.ajax({
      url: "http://my.domain-blahblah.com.au/scripts/touchscreen_email.cfm?name="+encodeURIComponent(userName)+"&phone="+encodeURIComponent(userPhone)+"&email="+encodeURIComponent(userEmail)+"&query="+encodeURIComponent(userQuery), success: success, error: failure});

}

它会触发一个非常简单的 CFMAIL 命令,在调用时从 URL 中的各个参数中提取值...

问题是它告诉我每次调用该函数时它都会因“失败”弹出窗口而失败......但仍然会正确触发电子邮件。ColdFusion 完美无瑕。所以我在想我的 Ajax 一定是在某个地方搞砸了......

知道我可能会错过什么吗?

服务器端代码:

    <cftry>
<cfmail from="touchscreen@my.domain-blahblah.com.au" to="eliseo.dannunzio@my.domain-blahblah.com.au" subject="Touchscreen Data" type="html" spoolenable="yes">
    <head>
        <style type="text/css">
            body {
                font-family: 'Calibri';
                font-size: 12pt;
            }

            h3 {
                margin: 0px 0px 8px 0px;
                padding: 0px 0px 0px 0px;   
            }

            span {
                font-weight: bold;  
            }
        </style>
    </head>

    <body>
        <h3>Touchscreen Data</h3>
        <p>
            <span>Name: </span>#url.name#<br />
            <span>Phone: </span>#url.phone#<br />
            <span>E-Mail: </span>#url.email#<br />
            <span>Request: </span>#url.query#<br />
            <span>Timestamp: </span>#DateFormat(Now(), "dd mmm yyyy")# #TimeFormat(Now(), "hh:mm tt")#<br />
        </p>
    </body>
</cfmail>
<cfcatch type="any">
    #cfcatch.Message# - #cfcatch.Detail#
</cfcatch>
</cftry>
Done
4

2 回答 2

1

像这样做ajax请求不是更好吗?

var request = $.ajax({
  url: "http://my.domain-blahblah.com.au/scripts/touchscreen_email.cfm",
  type: "get",
  date: { name : encodeURIComponent(userName), phone : encodeURIComponent(userPhone), email : encodeURIComponent(userEmail), query : encodeURIComponent(userQuery)},
  success: success,
  error: failure
});
于 2012-10-18T06:42:54.203 回答
0

你试过这样做吗....我认为这是调用 ajax 的正确方法

$.ajax({
  url: "http://my.domain-blahblah.com.au/scripts/touchscreen_email.cfm",
  data:{name:encodeURIComponent(userName),phone:encodeURIComponent(userPhone),email:encodeURIComponent(userEmail),query:encodeURIComponent(userQuery)}, 
  type:'GET',
  success: function(msg){ //do something here }, 
  error: failure
 });
于 2012-10-18T06:45:45.187 回答