Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I've created a sample for you consisting of an index.htm and a system.cfc
- Index.htm
- <html>
- <head>
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
- <script>
- $(document).ready(function(){
- $(".getData").click( function(){
- var method = $(this).attr("method");
- $.getJSON( "system.cfc?method="+method,
- function(data) {
- $("#res").val( data.server_name )
- });
- });
- });
- </script>
- </head>
- <body>
- <textarea style="height:200px;width:200px;" id="res"></textarea>
- <input type="button" class="getData" method="getCgi1" value="Get Json 1" />
- <input type="button" class="getData" method="getCgi2" value="Get Json 2" />
- <input type="button" class="getData" method="getCgi3" value="Get Json 3" />
- </body>
- </html>
- system.cfc
- <cfcomponent>
- <cffunction name="getCgi1" access="remote" returnFormat="json" output="false">
- <cfreturn cgi />
- </cffunction>
- <cffunction name="getCgi2" access="remote" returnFormat="plain" output="false">
- <cfreturn serializeJSON(cgi) />
- </cffunction>
- <cffunction name="getCgi3" access="remote" returnFormat="plain" output="false">
- <cfset var customCgi = '{"server_name": "#cgi.server_name#","server_port": "#cgi.server_post#"}' />
- <cfreturn customCgi />
- </cffunction>
- </cfcomponent>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement