I am using ColdFusion function shown below:
<cffunction name="getdata" access="remote" output="true" returntype="string">
<cfargument name="x" type="string" required="true">
<cfargument name="y" type="string" required="true">
<cfquery name="getval" datasource="#application.datasource#" result="result">
select val from table where col1=#arguments.x# and col2=#arguments.y#
</cfquery>
<cfset p= #getval.val#>
<cfreturn p>
</cffunction>
I want the value of val
to be printed in an alert. Alert displayed should be "please verify whether it's val" when user selects one of the values in autocomplete drop down.
How can I achieve this?
I tried using jQuery AJAX inside select event in autocomplete, here x
and y
are the names of input fields on the form:
select: function(event, ui) {
$.ajax({
type: "GET",
url: 'somepathtofunction?method=getdata&x='+ x + '&y'+ y,
async: true,
success: function(result) {
alert('please verify whether it is' + result.val );
}
});
}
Also, tried the code below:
alert('please verify whether it is' + $.get('somepathtofunction?method=getdata&x='+ x + '&y'+ y));
but none of these worked.
I am new to jQuery AJAX and ColdFusion so I know I have written most of the wrong code. Kindly correct me wherever I am wrong.