PFA
ThanksOn Thu, Jan 30, 2014 at 3:57 PM, Adarsh Sharma <eddy.adarsh@xxxxxxxxx> wrote:
ThanksIt the end of the above link , you can see the exact value of user.Agreed Nikha. Valid point. See i tested by added one line in my code :When i run it , it gives me exact value of the user which i chooses. If my user variable is empty then my output should be blank. Also,document.write(users);
var users = document.getElementById('users').value;
var queryString = "?users=" + users ;
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();
http:///db11.app.com/project/ajaxex.php?q=133
On Thu, Jan 30, 2014 at 3:50 PM, Domain nikha.org <mail@xxxxxxxxx> wrote:
Adarsh Sharma am Donnerstag, 30. Januar 2014 - 10:39:
> Thanks Nikha but its already dere :
>
> <html>
> <head>
> <script>
> function week_report_fun(){
> var ajaxRequest; // The variable that makes Ajax possible!
>
> try{
> // Opera 8.0+, Firefox, Safari
> ajaxRequest = new XMLHttpRequest();
> }catch (e){
> // Internet Explorer Browsers
> try{
> ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
> }catch (e) {
> try{
> ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
> }catch (e){
> // Something went wrong
> alert("Your browser broke!");
> return false;
> }
> }
> }
> ajaxRequest._onreadystatechange_ = function(){
> if(ajaxRequest.readyState == 4){
> var ajaxDisplay = document.getElementById('ajaxDiv');
> ajaxDisplay.innerHTML = ajaxRequest.responseText;
> }
> }
> var users = document.getElementById('users').value;
> var queryString = "?users=" + users ;
> //document.write(queryString);
> ajaxRequest.open("GET","ajaxex.php?q="+users,true);
> ajaxRequest.send();
> }
>
> </script>
> </head>
> <body>
>
> <form>
> User : <select id="users">
> <option value="">Select a user</option>> <option value="133">a.v</option>
> <option value="168">ad</option>
> </select>> Thanks
> <input type='button' _onclick_="week_report_fun()"
> value='Weekly Report'/>
> </form>
> <br>
>
> </body>
> </html>
>
>
> Sorry My bad , i didn't mention the complete program in my first mail
>
>
>
> On Thu, Jan 30, 2014 at 2:36 PM, Domain nikha.org <mail@xxxxxxxxx> wrote:
>
> > Adarsh Sharma am Donnerstag, 30. Januar 2014 - 07:27:
> >
> > > Hi,
> > >
> > > I am using AJAX and php for creating a small UI that retrieves data from
> > > mysql upon clicking on one button. But i clicked on that , nothing is
> > > happening. Below is my index.html :
> > >
> > > *-- index.html *
> > >
> > > <html>
> > > <head>
> > > function week_report_fun(){
> > > var ajaxRequest;
> > > ---
> > > ---
> > > --
> > > ajaxRequest.open("GET","ajaxex.php?q="+users,true);
> > > ajaxRequest.send();> > > *Access Log Output :-*
> > > }
> > >
> > > </script></head><body>
> > > <form>
> > > User : <select id="users" _onchange_="week_report_fun()">
> > > <option value="">Select a user</option>
> > > <option value="133">av</option>
> > > <option value="168">ad</option>
> > > <option value="78">so</option>
> > > <option value="239">ak</option>
> > > </select></form><br>
> > > <div id="txtHint"><b>Person info will be listed here.</b></div>
> > > </body></html>
> > >
> > >
> > > 1.4.15.25 - - [30/Jan/2014:06:05:52 +0000] "GET /project/ajaxex.php?q=133
> > > HTTP/1.1" 200 5323 "http://db11.app.com/project/" "Mozilla/5.0
> > (Macintosh;> > > 1.4.15.25 - - [30/Jan/2014:06:06:13 +0000] "GET
> > > Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko)
> > > Chrome/32.0.1700.102 Safari/537.36"
> > /project/ajaxex.php?q=133
> > > HTTP/1.1" 200 5323 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1)
> > > AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.102
> > Safari/537.36"
> > >
> > > No errors in error.log.OK!
> > >
> > > Strange thing if i directly open below link in the browser, report is
> > > coming and i am able to see in the browser :
> > >
> > > *http:///db11.app.com/project/ajaxex.php?q=133
> > > <http://db11.app.com/project/ajaxex.php?q=133>*
> > >
> > > It means my ajaxex.php is fine and no issues but dont understand why it
> > is
> > > not working as expected after clicking on button.Please let me know if i
> > am
> > > missing something.
> > >
> > >
> > > Thanks
> > >
> > Hi Adarsh!
> > Yes, you are missing something: The opening <script> tag in your html head!
> > without that, your ajax code is simply ignored.
> >
> > Hope it helps
> > Niklaus
> >
>
Consider to give names to the <form> and the <select> tag.
FI:
<form name="selector">
<select name="user">
Then you can point to them in your _javascript_ like this:
var users = document.selector.user.value
Actualy, your users variable is just empty, what is not an error. So you have no error reported.
Niklaus
Attachment:
ajaxex.php
Description: application/httpd-php
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php