User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 402,743 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,505 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

how to send request to server for a .aspx page to open through javascript code

Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,165
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Rep Power: 7
Solved Threads: 59
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: how to send request to server for a .aspx page to open through javascript code

  #2  
Aug 2nd, 2007
You mean AJAX ?

  1. //////////////////////////////////////////////////////////////////////////
  2. //
  3. // Author: Holly Styles
  4. // Copyright: Weblogik 2006
  5. //
  6. // Description; basic AJAX framework for ASP.NET projects
  7. //
  8. // Usage:
  9. // Implement two functions to handle successfull and failed requests.
  10. // In your page create an instance of responseHandler(fnSuccess, fnFail)
  11. // passing references to the above functions in the constructor.
  12. // call the executeRequester(method, url, cgi, myHandler) function,
  13. //
  14. // Examples:
  15. // function mySuccessHandler(requester){ alert(requester.responseText); }
  16. // function myFailedHandler(requester){ alert("Request failed!"); }
  17. //
  18. // var myHandler = new responseHandler(mySuccessHandler, myFailedHandler)
  19. //
  20. // executeRequester("GET", "YourPage.aspx", "", myHandler);
  21. // executeRequester("GET", "YourPage.aspx", "ID=1&value=value", myHandler);
  22. // executeRequester("POST", "YourPage.aspx", "ID=1&value=value", myHandler);
  23. //
  24. // Compatability:
  25. // IE 6, Firefox 1.5, (opera, safari, etc. should work but not tested)
  26. //
  27. /////////////////////////////////////////////////////////////////////////////
  28. function newRequester()
  29. {
  30.  
  31. var requester;
  32. try
  33. {
  34. requester = new XMLHttpRequest();
  35. }
  36. catch(error)
  37. {
  38.  
  39. try
  40. {
  41.  
  42. requester = new ActiveXObject("Microsoft.XMLHTTP");
  43. }
  44. catch(error)
  45. {
  46. alert(error);
  47. requester = null;
  48. }
  49. }
  50. return requester;
  51. }
  52.  
  53. function executeRequester(method, url, cgi, handler)
  54. {
  55. var requester = newRequester();
  56.  
  57. requester.onreadystatechange = function()
  58. {
  59. if(requester.readyState == 4)
  60. {
  61. if(requester.status == 200 || requester.status == 304)
  62. {
  63. handler.success(requester, url);
  64. handler = null;
  65. }
  66. else
  67. {
  68. handler.fail(requester, url);
  69. handler = null;
  70. }
  71. }
  72. return true;
  73. };
  74.  
  75. method = method.toUpperCase();
  76.  
  77. if(method == "GET" && cgi != "")
  78. {
  79. url = url + "?" + cgi;
  80. }
  81.  
  82. requester.open(method, url, true);
  83. requester.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  84.  
  85. if(method == "POST")
  86. {
  87. requester.send(cgi);
  88. }
  89. else
  90. {
  91. requester.send(null);
  92. }
  93. }
  94.  
  95. function responseHandler(fnSuccess, fnFail)
  96. {
  97. this.success = fnSuccess;
  98. this.fail = fnFail;
  99. }
  100.  
  101.  
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote  
All times are GMT -4. The time now is 7:48 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC