By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,253 Members | 1,701 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,253 IT Pros & Developers. It's quick & easy.

how to load o/p of php in current page using js?

P: 1
hi i am new to web development and i am using js/ajax code to load o/p of php file in <div> tag. Now i am using a login.php file and i want that if login credentials are correct then further page should be open in current window else login fail message should be displayed below the username and password text box. following is the code i am using -
Expand|Select|Wrap|Line Numbers
  1. function updateLink(id,pwd){
  2.     var oRequest;
  3.     try {
  4.         oRequest=new XMLHttpRequest();
  5.     } catch (e)   {
  6.         try {
  7.             oRequest=new ActiveXObject("Msxml2.XMLHTTP");
  8.         } catch (e) {
  9.             try {
  10.                 oRequest=new ActiveXObject("Microsoft.XMLHTTP");
  11.             } catch (e) {
  12.                 alert("Your browser does not support AJAX!");
  13.                 return false;
  14.             }
  15.         }
  16.     }
  17.     oRequest.onreadystatechange=function() {
  18.         if(oRequest.readyState==4)
  19.         {
  20.             var div = window.parent.document.getElementById('result');
  21.             div.innerHTML = oRequest.responseText;
  22.         }
  23.     }
  24.     var url = "updateLinks.php";
  25.     url = url+"?id="+id;
  26.     url = url+"&pass="+pwd
  27.     oRequest.open("GET",url,true);
  28.     oRequest.send(null);
  29. }
  30.  
how can i modify the above code to do above written task?
Feb 24 '10 #1

✓ answered by Dormilich

I would use a plain form for that and let PHP decide what page to load. works even with JavaScript disabled.

Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
I would use a plain form for that and let PHP decide what page to load. works even with JavaScript disabled.
Feb 24 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.