Advertisement
Guest User

Code for having Excel File generated without Page refresh Jq

a guest
Mar 8th, 2012
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script><script language="javascript">
  5. $(document).ready(function(e) {
  6. $("#sbtUser").on('click',function(){
  7.         var name = $("#name").val();
  8.         var org = $("#organisation").val();
  9.         var city = $("#city").val();
  10.         if(name == '' || org == '' || city == '')
  11.         {
  12.             alert('Please Provide Name, Organization and City values');
  13.         }
  14.         else
  15.         {
  16.             $(this).attr('disabled', 'disabled');
  17.             var str = $("form").serialize();
  18.             $.ajax({
  19.                 type:"GET",
  20.                 url:"submit.cfm",
  21.                 data:str,
  22.                 success:function(html) {
  23.                 $("#message").html(html);
  24.                 }
  25.             });
  26.         }
  27.     });
  28. });
  29. </script>
  30. <input type="text" id="testString" placeholder="Enter test string">
  31. <button id="sbtUser">Test</button>
  32. </body>
  33. </html>
  34.  
  35. other Page submit.cfm, i just did like this
  36.  
  37. <cfsetting showdebugoutput="no">
  38. <cfsavecontent variable="a">
  39. #url.testString#
  40. </cfsavecontent>
  41. <cffile action="write" file="#ExpandPath("excel")#\#Dateformat(now(),'dd_mm_yyyy')#_#TimeFormat(now(),'hh_mm_ss_tt')#.xls" output="#a#">
  42. Thanks For your Survey, we have stored Your Information
  43.  
  44. That's it, it created excel on fly and stored it on the PC and showed a message to user without page refresh
  45.  
  46. Cheers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement