mxData

4 views
Skip to first unread message

Lance

unread,
Sep 17, 2008, 5:59:20 PM9/17/08
to mxAjax
I am new at mxAjax and trying to get mxData to work. Here is my code:

<cfset ajaxUrl = "http://"&cgi.server_name&":"&cgi.server_port&"/
shared/cfc/ajaxTest2.cfc">
<script language="javascript">
var url = "<cfoutput>#ajaxUrl#</cfoutput>";

function clickTrack(){
alert('firing');
new mxAjax.Data({
executeOnLoad: true,
paramArgs: new mxAjax.Param(url,{param:"clickObj='button 1 was
pushed'", httpMethod:"post", cffunction:"enterSiteStat"}),
postFunction: handleData,
errorFunction: sayError
});
alert('firing complete');
}
function handleData(response){
alert(response);
}
function sayError(){
alert('error');
}
</script>

<h1>Test mxData</h1>
<form name="myForm" action="mylookup.cfm" method="post">
<input type="button" name="process" value="button 1"
onClick="clickTrack()"><br>
<input type="button" name="process2" value="button 2" onClick="new
Ajax.Updater('divResponse', url + '?
method=init&function=enterSiteStat&clickObj=button 2 was
pushed&htmlResponse=true')"><br>
</form>
<div id="divResponse"></div>


Here is the cfc :

<cfcomponent extends="mxAjax.core.cf.mxAjax" output="false">
<cfapplication name="mxAjax" sessionmanagement="true">


<cffunction name="enterSiteStat" access="public" output="false"
returntype="string">
<cfargument name="clickObj" type="string" required="false"
default="">

<cfreturn arguments.clickObj/>
</cffunction>
</cfcomponent>

If I press Button 2 I get the ecpected result but if I press Button 1
I get a js error: Object expected

I have been trying to figure this out for hours and I know there s
something simple I am missing. Any help is appriciated!

James Holmes

unread,
Sep 17, 2008, 10:32:52 PM9/17/08
to mxa...@googlegroups.com
Are you loading in all of the required mxAjax scripts? Perhaps post
this section of your code.

On Thu, Sep 18, 2008 at 6:59 AM, Lance <cfprog...@yahoo.com> wrote:
>
> I am new at mxAjax and trying to get mxData to work. Here is my code:


--
mxAjax / CFAjax docs and other useful articles:
http://www.bifrost.com.au/blog/

Lance

unread,
Sep 19, 2008, 1:55:22 PM9/19/08
to mxAjax
Thx James. I guess since I was using the examples everything was
working but when I started writing my own I didn't realize that each
mx function had it's own script that had to loaded. I guess I that
part of the mxAjax script would load the need scripts. Once I loaded
the mxData script everything worked great!
Reply all
Reply to author
Forward
0 new messages