I am using JQuery and AJAX along with ColdFusion. I have some value in the URL http://mysitedomain.com/something/page.cfm?x=229 I want this value of x as an argument to my ColdFusion function.
Can somebody please tell me how can I pass value of x in URL as an argument to my ColdFusion function using AJAX or any other way?
I don't know how it works but still I tried doing this: AJAX code:
$.ajax({
type: "GET",
url: 'SomePathTocfc?method=getsomething&x='+x,
async: true,
success: function(result){
document.getElementById('abc').value = "My Text Input";
}
});
ColdFusion function:
<cffunction name="getsomething" access="remote" output="true">
<cfargument name="x" type="string" required="true">
<cfquery name="getReq" datasource="#application.dbsrc#" result =result>
Select * from TableName
Where
<cfif isDefined("arguments.x") >
x = #arguments.x#
</cfif>
</cfquery>
</cffunction>
just use
<cfargument name="inparam" type="struct">and you will get the url value as a structure and you can use it and do a<cfdump var="#arguments#">and you will see your passed parameters, you can use them like this