Domanda

I'm updating a variable based on the value selected from a drop-down list, and it just isn't working.

On this site I have another CFC which is working fine, however this one is just downright refusing to post the data.

jQuery

$('.accessLevel').change(function() {
    var theValue = $('.accessLevel').val();
    $.ajax({
        type: "post",
        url: "setLevel.cfc",
        data: {
            method: "theLevel",
            alevel: theValue
        },
        dataType: "json",
        success: function(){
            alert('YES');
        },
        error: function(){
            alert('NO');
        }
    });    
 })

HTML

<select name="accessLevel" class="accessLevel">
   <option value="">Select an Access Level</option>
   <option value="1">Level One</option>
   <option value="2">Level Two</option>
   <option value="3">Level Three</option>
</select>

CFC

<cfcomponent>
  <cffunction name="theLevel" access="remote" returntype="any">
    <cfargument name="alevel" type="any" required="yes">
    <cfset SESSION.accessLevel = argument.alevel>
    <cfreturn />
  </cffunction>
</cfcomponent>

The variable theValue is being populated, it just won't pass through to the CFC and I have no idea why! The error I'm getting is this..

Element ALEVEL is undefined in ARGUMENT.
È stato utile?

Soluzione

In regards to that error, the scope name is arguments (with an s), not argument. Try changing that and see if you get passed that error.

 <cfset SESSION.accessLevel = arguments.alevel>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top