Loosing variables posted by Ajax Post (Coldfusion 10)
Hello every body. There is 7h that I search, I try examples from your forum or from other blogs or google without finding a solution to my problem.
I explain
I have a form which contains the result of a search. On this result, you have a "trash" icon per item where the user can delete the selected record.
When he click on the icon, the system use a call ajax for deleting the record.
code:
jQuery('a[id^=Del_]').click(function(){
var id = jQuery(formfield).val();
var response = confirm("Are you sure to delete the current record ?");
if (response){
jQuery.ajax({
url: 'urlevent=MyfunctionDelete',
type: 'POST',
cache: false,
dataType: 'html',
data: {id:id},
success: function (data) {
alert('Record sucessfully deleted');
}
});
}
}
The "urlevent=MyfunctionDelete" is a call to a cfc page containing the function for deleting the record.
When I dump the content coming from server.
It is easy : EMPTY! No variables ... nothing.
When I look with the tool developer and I control the detail, I see that the content of "id" is really send with the right value.
the code of my function:
<cffunction name="MyfunctionDelete" access="public" output="false" returntype="struct">
<cfset var id = 0>
<cfif arguments.event.isArgDefined("id")>
<cfif isnumeric(arguments.event.getArg("id")) >
<cfset id = abs(arguments.event.getArg("id")) />
</cfif>
</cfif>
id:<cfdump var="#id#" /><br> <!--- response; 0 --->
<cfdump var="#arguments.event.getargs()#" /><br> <!--- response; empty --->
<cfabort>
<!--- .... rest of the code --->
</cffunction>
I don't see my mistake. There is a configuration with coldfusion server about ajax?
I use jQuery version : v3.2.1, Bootstap 3.0 and Colfusion ver 10.
Any help is welcome
Thank you in advance
Best regards
Andre
