return variable undefined in jQuery $.post sent by a cfc

I am using $.post() to send a json to my cfc, which updates some records. I am not returning a json back to the calling page, I am just returning the contents of a variable that I am setting in the cfc. Based on the value of that variable, the update was/was not successful. I cannot seem to get at the contents of the variable. I just started using jQuery, so I think I'm doing it right, but apparently not.

the jQuery:

$("#edit_button").click(function(){
    if(theArray.length > 0){
        theJson = JSON.stingify(theArray);
        $.post("cfcs/fund_profile.cfc",{
            method:"updateProfile",
            data:theJson,
            dataType:"text"
            success:function(response){alert(response);}
        });
   }
});

I'm not going to post the whole cfc, just the important part.

I am just returning a string.

<cffunction name="updateProfile" ...>
    ...

    <cfif message neq ''>
        <cfreturn message>
    <cfelse>
        <cfset message = "success">         
    </cfif>
    <cfreturn message>
</cffunction>

Answers


You are using $.post incorrectly. That looks like a mish-mash of $.ajax and $.post. Your call should resemble this:

$.post("cfcs/fund_profile.cfc",{ method: "updateProfile", data: theJson}, 
    function(response) {
       alert(response);
    }, 
"text");

Docs: http://api.jquery.com/jQuery.post/


Need Your Help

MSI Installer error 2203; how to force permissions on installer directory?

model-view-controller windows-7 permissions windows-installer asp.net-mvc-3

[Cross-Posted on SuperUser.com as well because the question relates to permissions. Feel free to let me know where it best belongs.]

how to get value?

jquery

How to get current selected value of a dropdown which is inside div?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.