Coldfusion:将 json 从一个 CFM 传递到另一个 CFM?
基本上,我从一个 CFM 调用另一个 CFM,它创建一个对象,调用该对象上的多个方法并登录用户;否则它会在屏幕上打印错误。
有没有办法获取 CFM 并将 JSON 对象发送到调用它的文件,而不是打印错误?
这是我的阿贾克斯:
// processing the login form using jQuery
$("#loginForm").submit(function(event){
// prevents the form from being submitted, the event is the arg to the function
event.preventDefault();
// stores the data from the form into a variable to be used later
dataString = $("#loginForm").serialize();
// the AJAX request
$.ajax
({
type: "POST",
url: "/helpers/auth/ldap/login_demo.cfm",
data: dataString,
//dataType: "text",
success: function()
{
location.reload();
},
error: function(ErrorMsg)
{
$("#hiddenLoginError").show("fast");
$("#loginForm p").css("margin-bottom","3px");
}
});
});
Basically I am calling from a CFM another CFM which creates an object, calls several methods on this object and logs a user in; otherwise it prints an error on the screen.
Rather then printing the Error, is there a way to take a CFM and have it send a JSON object to the file that called it?
Here's my ajax:
// processing the login form using jQuery
$("#loginForm").submit(function(event){
// prevents the form from being submitted, the event is the arg to the function
event.preventDefault();
// stores the data from the form into a variable to be used later
dataString = $("#loginForm").serialize();
// the AJAX request
$.ajax
({
type: "POST",
url: "/helpers/auth/ldap/login_demo.cfm",
data: dataString,
//dataType: "text",
success: function()
{
location.reload();
},
error: function(ErrorMsg)
{
$("#hiddenLoginError").show("fast");
$("#loginForm p").css("margin-bottom","3px");
}
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的 CFM 页面上,您可以使用
语句来检查该页面是否是通过 ajax 请求的。如果是ajax,则返回一个json对象。然后你可以测试响应:
On your CFM page, you can have a
<cfif>
statement that checks whether the page was requested with ajax or not. If it was ajax, return a json object.you can then test the response:
尝试:
Try: