简体   繁体   English

ColdFusion调用Ajax的CFC页面

[英]ColdFusion Calling CFC page for ajax

Hey all I am trying to call the following cfm page in order to call a cfc page via ajax: 嘿,我正在尝试调用以下cfm页,以便通过ajax调用cfc页:

https://dev-thesite.com/personnel/search.cfm page: https://dev-thesite.com/personnel/search.cfm页面:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script>      
 $(document).ready(function() {
    $.ajax({
        type:'GET',
        url: 'search_ajax.cfc?method=searchAward',
        data: {
            Totals:'100', 
            CodeNum:'165161', 
            TestYear:'2016',
            SelType:'blah', 
            SelJuris:'juris'
        },
        success: function(data) {
            alert(data);
        },
        error: function(data) {
            console.log('err: ', data);
        }
    });
 });     
 </script>
 <div id="testing"></div>

https://dev-thesite.com/personnel/search_ajax.cfc page: https://dev-thesite.com/personnel/search_ajax.cfc页面:

<cfcomponent>
    <cffunction name="searchAward" access="remote" returntype="string">
            <cfargument name="Totals" type="string" required="true">
            <cfargument name="CodeNum" type="string" required="true">
            <cfargument name="TestYear" type="string" required="true">
            <cfargument name="SelType" type="string" required="true">
            <cfargument name="SelJuris" type="string" required="true"> 
        <cfscript>
            if(arguments.Totals = '5'){
                return 'YES!';
            } else {
                return 'NO!';
            }
        </cfscript>
    </cffunction>
</cfcomponent>

Currently when running this I get the error side of the ajax call. 当前,运行此命令时,我得到了ajax调用的错误信息

500 - Internal server error. 500内部服务器错误。

There is a problem with the resource you are looking for, and it cannot be displayed. 您正在寻找的资源有问题,无法显示。

Any help would be great at fixing this error in ColdFusion 9! 任何帮助都可以在ColdFusion 9中更正此错误!

Well it looks like all that was wrong was changing this: 好吧,似乎所有错误的地方都在改变这一点:

if(arguments.Totals = '5'){

to this: 对此:

if(arguments.Totals eq '5'){

Just adding the eq seems to have fixed it oddly enough. 仅添加eq似乎已将其固定得很奇怪。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM