Discussion:
PHP output fails from AJAX call
Adarsh Sharma
2014-01-30 06:27:44 UTC
Permalink
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();
}

</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>

*Access Log Output :-*

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;
Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/32.0.1700.102 Safari/537.36"
1.4.15.25 - - [30/Jan/2014:06:06:13 +0000] "GET /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.

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
Adarsh Sharma
2014-01-30 06:33:53 UTC
Permalink
Missed the button code :-
<input type='button' onclick="week_report_fun()"
value='Weekly Report'/>

Tried with onchange functionality as well but still not working.

Thanks
Post by Adarsh Sharma
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
*-- index.html *
<html>
<head>
function week_report_fun(){
var ajaxRequest;
---
---
--
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();
}
</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>
*Access Log Output :-*
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; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/32.0.1700.102 Safari/537.36"
1.4.15.25 - - [30/Jan/2014:06:06:13 +0000] "GET /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.
Strange thing if i directly open below link in the browser, report is
*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
Domain nikha.org
2014-01-30 09:06:01 UTC
Permalink
Post by Adarsh Sharma
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
*-- index.html *
<html>
<head>
function week_report_fun(){
var ajaxRequest;
---
---
--
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();
}
</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>
*Access Log Output :-*
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;
Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/32.0.1700.102 Safari/537.36"
1.4.15.25 - - [30/Jan/2014:06:06:13 +0000] "GET /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.
Strange thing if i directly open below link in the browser, report is
*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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Adarsh Sharma
2014-01-30 09:39:09 UTC
Permalink
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>
<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


Thanks
Post by Adarsh Sharma
Post by Adarsh Sharma
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
*-- index.html *
<html>
<head>
function week_report_fun(){
var ajaxRequest;
---
---
--
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();
}
</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>
*Access Log Output :-*
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;
Post by Adarsh Sharma
Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/32.0.1700.102 Safari/537.36"
1.4.15.25 - - [30/Jan/2014:06:06:13 +0000] "GET
/project/ajaxex.php?q=133
Post by Adarsh Sharma
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"
Post by Adarsh Sharma
No errors in error.log.
Strange thing if i directly open below link in the browser, report is
*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
Post by Adarsh Sharma
not working as expected after clicking on button.Please let me know if i
am
Post by Adarsh Sharma
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
Tim Streater
2014-01-30 09:42:00 UTC
Permalink
Post by Adarsh Sharma
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
*-- index.html *
<html>
<head>
Missing <script ... > as Niklaus has pointed out.
Post by Adarsh Sharma
function week_report_fun(){
var ajaxRequest;
---
---
--
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
What is "users"? Where is your code to get the selected value from the form?
Post by Adarsh Sharma
ajaxRequest.send();
}
</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>
Where is your code to get the returned results from your PHP script and display it?
--
Cheers -- Tim
Adarsh Sharma
2014-01-30 09:45:03 UTC
Permalink
Below is my ajaxex.php :-

[root@]# cat ajaxex.php
<?php

$q = intval($_GET['q']);

$con=mysqli_connect("db11.app.com","root","123","ots")
;

if (!$con)
{
die('Could not connect: ' . mysqli_error($con));
}

$result = mysqli_query($con,"SELECT us.login user,WEEK(cw.create_time,
'%Y-%m') AS WEEK,min(cw.create_time) ws ,max(cw.create_time) we,COUNT(*) AS
total_cr FROM
change_item cw,users us where cw.create_time < now() and cw.create_by=
us.id and cw.create_by = '".$q."' GROUP BY 1,2");

//Build Result String
echo "<table border='1'>
<tr>
<th>user</th>
<th>WEEK</th>
<th>ws</th>
<th>we</th>
<th>total_cr</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['user'] . "</td>";
echo "<td>" . $row['WEEK'] . "</td>";
echo "<td>" . $row['ws'] . "</td>";
echo "<td>" . $row['we'] . "</td>";
echo "<td>" . $row['total_cr'] . "</td>";
echo "</tr>";
}

echo "</table>";

?>

Thanks
Post by Tim Streater
Post by Adarsh Sharma
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
*-- index.html *
<html>
<head>
Missing <script ... > as Niklaus has pointed out.
Post by Adarsh Sharma
function week_report_fun(){
var ajaxRequest;
---
---
--
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
What is "users"? Where is your code to get the selected value from the form?
Post by Adarsh Sharma
ajaxRequest.send();
}
</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>
Where is your code to get the returned results from your PHP script and display it?
--
Cheers -- Tim
Tim Streater
2014-01-30 09:54:00 UTC
Permalink
Post by Adarsh Sharma
var users = document.getElementById('users').value;
You probably want:

var ptr = document.getElementById('users');
var ind = ptr.selectedIndex;
var users = ptr.options[ind].value;
--
Cheers -- Tim
Adarsh Sharma
2014-01-30 10:04:16 UTC
Permalink
Tried but still not working :(

Actually i think value is clearly passing to the function and then to the
ajaxex.php. I tested by printing the exact value :

//document.write(queryString);

and it is showing the exact value of the user that you chooses. So , i dont
think problem lies in the value.

Access log clearly says it executed ajaxex.php without any issues :

1.4.12.25 - - [30/Jan/2014:09:58:31 +0000] "GET
/project/ajaxex.*php?q=133*HTTP/1.1" 200
*6093* "http://db11.app.com/project/" "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"

It trasferred about 6093 bytes after executing ajaxex.php but dont know
why it is not coming after clicking on the button.

Strange thing is if you execute directly
*http://db11.app.com/project/ajaxex.php?q=133
<http://db11.app.com/project/ajaxex.php?q=133>* you will get the complete
report.


Thanks
Post by Tim Streater
Post by Adarsh Sharma
var users = document.getElementById('users').value;
var ptr = document.getElementById('users');
var ind = ptr.selectedIndex;
var users = ptr.options[ind].value;
--
Cheers -- Tim
Domain nikha.org
2014-01-30 10:20:02 UTC
Permalink
Post by Adarsh Sharma
<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>
<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
Thanks
Post by Adarsh Sharma
Post by Adarsh Sharma
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
*-- index.html *
<html>
<head>
function week_report_fun(){
var ajaxRequest;
---
---
--
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();
}
</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>
*Access Log Output :-*
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;
Post by Adarsh Sharma
Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/32.0.1700.102 Safari/537.36"
1.4.15.25 - - [30/Jan/2014:06:06:13 +0000] "GET
/project/ajaxex.php?q=133
Post by Adarsh Sharma
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"
Post by Adarsh Sharma
No errors in error.log.
Strange thing if i directly open below link in the browser, report is
*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
Post by Adarsh Sharma
not working as expected after clicking on button.Please let me know if i
am
Post by Adarsh Sharma
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
OK!
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Adarsh Sharma
2014-01-30 10:27:42 UTC
Permalink
Agreed Nikha. Valid point. See i tested by added one line in my code :

var users = document.getElementById('users').value;
var queryString = "?users=" + users ;
* document.write(users); *
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();

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,

http:///db11.app.com/project/ajaxex.php?q=133

It the end of the above link , you can see the exact value of user.

Thanks
Post by Adarsh Sharma
Post by Adarsh Sharma
<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>
<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
Thanks
Post by Adarsh Sharma
Post by Adarsh Sharma
Hi,
I am using AJAX and php for creating a small UI that retrieves data
from
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
mysql upon clicking on one button. But i clicked on that , nothing is
*-- index.html *
<html>
<head>
function week_report_fun(){
var ajaxRequest;
---
---
--
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();
}
</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>
*Access Log Output :-*
1.4.15.25 - - [30/Jan/2014:06:05:52 +0000] "GET
/project/ajaxex.php?q=133
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
HTTP/1.1" 200 5323 "http://db11.app.com/project/" "Mozilla/5.0
(Macintosh;
Post by Adarsh Sharma
Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/32.0.1700.102 Safari/537.36"
1.4.15.25 - - [30/Jan/2014:06:06:13 +0000] "GET
/project/ajaxex.php?q=133
Post by Adarsh Sharma
HTTP/1.1" 200 5323 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X
10_9_1)
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.102
Safari/537.36"
Post by Adarsh Sharma
No errors in error.log.
Strange thing if i directly open below link in the browser, report is
*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
Post by Adarsh Sharma
Post by Adarsh Sharma
is
Post by Adarsh Sharma
not working as expected after clicking on button.Please let me know
if i
Post by Adarsh Sharma
Post by Adarsh Sharma
am
Post by Adarsh Sharma
missing something.
Thanks
Hi Adarsh!
Yes, you are missing something: The opening <script> tag in your html
head!
Post by Adarsh Sharma
Post by Adarsh Sharma
without that, your ajax code is simply ignored.
Hope it helps
Niklaus
OK!
Consider to give names to the <form> and the <select> tag.
<form name="selector">
<select name="user">
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
Stuart Dallas
2014-01-30 10:32:22 UTC
Permalink
Post by Adarsh Sharma
<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>
<input type='button' onclick="week_report_fun()"
value='Weekly Report'/>
</form>
<br>
</body>
</html>
I see no ajaxDiv in your HTML.

If you’re not using the developer console on your chosen browser (or an extension that provides that functionality, e.g. FireBug for Firefox) then you should be. JS raises errors like any other language, so if something is going wrong that will tell you all about it.

-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Adarsh Sharma
2014-01-30 10:36:00 UTC
Permalink
PFA

Thanks
Post by Adarsh Sharma
var users = document.getElementById('users').value;
var queryString = "?users=" + users ;
* document.write(users); *
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();
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,
http:///db11.app.com/project/ajaxex.php?q=133
It the end of the above link , you can see the exact value of user.
Thanks
Post by Adarsh Sharma
Post by Adarsh Sharma
<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>
<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
Thanks
Post by Adarsh Sharma
Post by Adarsh Sharma
Hi,
I am using AJAX and php for creating a small UI that retrieves data
from
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
mysql upon clicking on one button. But i clicked on that , nothing
is
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
*-- index.html *
<html>
<head>
function week_report_fun(){
var ajaxRequest;
---
---
--
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();
}
</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>
*Access Log Output :-*
1.4.15.25 - - [30/Jan/2014:06:05:52 +0000] "GET
/project/ajaxex.php?q=133
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
HTTP/1.1" 200 5323 "http://db11.app.com/project/" "Mozilla/5.0
(Macintosh;
Post by Adarsh Sharma
Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/32.0.1700.102 Safari/537.36"
1.4.15.25 - - [30/Jan/2014:06:06:13 +0000] "GET
/project/ajaxex.php?q=133
Post by Adarsh Sharma
HTTP/1.1" 200 5323 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X
10_9_1)
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.102
Safari/537.36"
Post by Adarsh Sharma
No errors in error.log.
Strange thing if i directly open below link in the browser, report
is
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
*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
Post by Adarsh Sharma
Post by Adarsh Sharma
is
Post by Adarsh Sharma
not working as expected after clicking on button.Please let me know
if i
Post by Adarsh Sharma
Post by Adarsh Sharma
am
Post by Adarsh Sharma
missing something.
Thanks
Hi Adarsh!
Yes, you are missing something: The opening <script> tag in your html
head!
Post by Adarsh Sharma
Post by Adarsh Sharma
without that, your ajax code is simply ignored.
Hope it helps
Niklaus
OK!
Consider to give names to the <form> and the <select> tag.
<form name="selector">
<select name="user">
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
Domain nikha.org
2014-01-30 11:15:49 UTC
Permalink
Post by Adarsh Sharma
PFA
Thanks
Post by Adarsh Sharma
var users = document.getElementById('users').value;
var queryString = "?users=" + users ;
* document.write(users); *
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();
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,
http:///db11.app.com/project/ajaxex.php?q=133
It the end of the above link , you can see the exact value of user.
Thanks
Post by Adarsh Sharma
Post by Adarsh Sharma
<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>
<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
Thanks
Post by Adarsh Sharma
Post by Adarsh Sharma
Hi,
I am using AJAX and php for creating a small UI that retrieves data
from
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
mysql upon clicking on one button. But i clicked on that , nothing
is
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
*-- index.html *
<html>
<head>
function week_report_fun(){
var ajaxRequest;
---
---
--
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();
}
</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>
*Access Log Output :-*
1.4.15.25 - - [30/Jan/2014:06:05:52 +0000] "GET
/project/ajaxex.php?q=133
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
HTTP/1.1" 200 5323 "http://db11.app.com/project/" "Mozilla/5.0
(Macintosh;
Post by Adarsh Sharma
Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/32.0.1700.102 Safari/537.36"
1.4.15.25 - - [30/Jan/2014:06:06:13 +0000] "GET
/project/ajaxex.php?q=133
Post by Adarsh Sharma
HTTP/1.1" 200 5323 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X
10_9_1)
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.102
Safari/537.36"
Post by Adarsh Sharma
No errors in error.log.
Strange thing if i directly open below link in the browser, report
is
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
*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
Post by Adarsh Sharma
Post by Adarsh Sharma
is
Post by Adarsh Sharma
not working as expected after clicking on button.Please let me know
if i
Post by Adarsh Sharma
Post by Adarsh Sharma
am
Post by Adarsh Sharma
missing something.
Thanks
Hi Adarsh!
Yes, you are missing something: The opening <script> tag in your html
head!
Post by Adarsh Sharma
Post by Adarsh Sharma
without that, your ajax code is simply ignored.
Hope it helps
Niklaus
OK!
Consider to give names to the <form> and the <select> tag.
<form name="selector">
<select name="user">
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
Hard case, I think!
Thanks for your PHP script. What happens, if you run it without the preliminary javascript UI?

The database query looks very complicated. I'm not realy an expert in mysqli. But as far as I experienced that, "SELECT" expects a _comma separated_ list of valid expressions before the "FROM" keyword. You have blanks there, like "us.login user" and others. Are you shure about this?

mysqli_query() does not return error messages, so you have blanc pages if it failes,

I think, you should have a look to the Mysql manual...
Niklaus
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Adarsh Sharma
2014-01-30 11:25:02 UTC
Permalink
There is no error in mysql queries i.e i told earlier if u opens the below
link directly :

*http://db11.app.com/project/ajaxex.php?q=133
<http://db11.app.com/project/ajaxex.php?q=133>*

you will get the complete report so no issues with ajaxex.php.

but i need the same after clicking on Weekly Report Command button when i
opened



*http://db11.app.com/project
<http://db11.app.com/project/ajaxex.php?q=133> and chooses one user.*

*Thanks*
Post by Adarsh Sharma
Post by Adarsh Sharma
PFA
Thanks
Post by Adarsh Sharma
var users = document.getElementById('users').value;
var queryString = "?users=" + users ;
* document.write(users); *
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();
When i run it , it gives me exact value of the user which i chooses.
If my
Post by Adarsh Sharma
Post by Adarsh Sharma
user variable is empty then my output should be blank. Also,
http:///db11.app.com/project/ajaxex.php?q=133
It the end of the above link , you can see the exact value of user.
Thanks
Post by Adarsh Sharma
Post by Adarsh Sharma
<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>
<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
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Thanks
Post by Adarsh Sharma
Post by Adarsh Sharma
Hi,
I am using AJAX and php for creating a small UI that retrieves
data
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
from
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
mysql upon clicking on one button. But i clicked on that ,
nothing
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
is
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
*-- index.html *
<html>
<head>
function week_report_fun(){
var ajaxRequest;
---
---
--
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();
}
</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>
*Access Log Output :-*
1.4.15.25 - - [30/Jan/2014:06:05:52 +0000] "GET
/project/ajaxex.php?q=133
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
HTTP/1.1" 200 5323 "http://db11.app.com/project/" "Mozilla/5.0
(Macintosh;
Post by Adarsh Sharma
Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/32.0.1700.102 Safari/537.36"
1.4.15.25 - - [30/Jan/2014:06:06:13 +0000] "GET
/project/ajaxex.php?q=133
Post by Adarsh Sharma
HTTP/1.1" 200 5323 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X
10_9_1)
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.102
Safari/537.36"
Post by Adarsh Sharma
No errors in error.log.
Strange thing if i directly open below link in the browser,
report
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
is
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
*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
Post by Adarsh Sharma
Post by Adarsh Sharma
is
Post by Adarsh Sharma
not working as expected after clicking on button.Please let me
know
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
if i
Post by Adarsh Sharma
Post by Adarsh Sharma
am
Post by Adarsh Sharma
missing something.
Thanks
Hi Adarsh!
Yes, you are missing something: The opening <script> tag in your
html
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
head!
Post by Adarsh Sharma
Post by Adarsh Sharma
without that, your ajax code is simply ignored.
Hope it helps
Niklaus
OK!
Consider to give names to the <form> and the <select> tag.
<form name="selector">
<select name="user">
var users = document.selector.user.value
Actualy, your users variable is just empty, what is not an error. So
you
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
have no error reported.
Niklaus
Hard case, I think!
Thanks for your PHP script. What happens, if you run it without the
preliminary javascript UI?
The database query looks very complicated. I'm not realy an expert in
mysqli. But as far as I experienced that, "SELECT" expects a _comma
separated_ list of valid expressions before the "FROM" keyword. You have
blanks there, like "us.login user" and others. Are you shure about this?
mysqli_query() does not return error messages, so you have blanc pages if it failes,
I think, you should have a look to the Mysql manual...
Niklaus
Adarsh Sharma
2014-01-30 11:35:19 UTC
Permalink
The one thing i doubts whether program control reaches to
ajaxex.php.Access_log says it is executing ajaxex.php. I tried to check
whether my program flow reaches to ajaxex.php by adding below lines in
ajaxex.php :

//echo "Mysql Connected";

//echo "Value of users : $q";

before the select command but after clicking on Weekly Report nothing
happens :(

Seems debugging is very difficult than to fix. There is no error in
error_log as well.

Thanks
Post by Adarsh Sharma
There is no error in mysql queries i.e i told earlier if u opens the
*http://db11.app.com/project/ajaxex.php?q=133
<http://db11.app.com/project/ajaxex.php?q=133>*
you will get the complete report so no issues with ajaxex.php.
but i need the same after clicking on Weekly Report Command button when i
opened
*http://db11.app.com/project
<http://db11.app.com/project/ajaxex.php?q=133> and chooses one user. *
*Thanks*
Post by Adarsh Sharma
Post by Adarsh Sharma
PFA
Thanks
Post by Adarsh Sharma
var users = document.getElementById('users').value;
var queryString = "?users=" + users ;
* document.write(users); *
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();
When i run it , it gives me exact value of the user which i chooses.
If my
Post by Adarsh Sharma
Post by Adarsh Sharma
user variable is empty then my output should be blank. Also,
http:///db11.app.com/project/ajaxex.php?q=133
It the end of the above link , you can see the exact value of user.
Thanks
Post by Adarsh Sharma
Post by Adarsh Sharma
<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>
<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
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Thanks
Post by Adarsh Sharma
Post by Adarsh Sharma
Hi,
I am using AJAX and php for creating a small UI that retrieves
data
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
from
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
mysql upon clicking on one button. But i clicked on that ,
nothing
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
is
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
*-- index.html *
<html>
<head>
function week_report_fun(){
var ajaxRequest;
---
---
--
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();
}
</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>
*Access Log Output :-*
1.4.15.25 - - [30/Jan/2014:06:05:52 +0000] "GET
/project/ajaxex.php?q=133
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
HTTP/1.1" 200 5323 "http://db11.app.com/project/" "Mozilla/5.0
(Macintosh;
Post by Adarsh Sharma
Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/32.0.1700.102 Safari/537.36"
1.4.15.25 - - [30/Jan/2014:06:06:13 +0000] "GET
/project/ajaxex.php?q=133
Post by Adarsh Sharma
HTTP/1.1" 200 5323 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X
10_9_1)
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.102
Safari/537.36"
Post by Adarsh Sharma
No errors in error.log.
Strange thing if i directly open below link in the browser,
report
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
is
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
*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
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
why it
Post by Adarsh Sharma
Post by Adarsh Sharma
is
Post by Adarsh Sharma
not working as expected after clicking on button.Please let me
know
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
if i
Post by Adarsh Sharma
Post by Adarsh Sharma
am
Post by Adarsh Sharma
missing something.
Thanks
Hi Adarsh!
Yes, you are missing something: The opening <script> tag in your
html
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
head!
Post by Adarsh Sharma
Post by Adarsh Sharma
without that, your ajax code is simply ignored.
Hope it helps
Niklaus
OK!
Consider to give names to the <form> and the <select> tag.
<form name="selector">
<select name="user">
var users = document.selector.user.value
Actualy, your users variable is just empty, what is not an error. So
you
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
have no error reported.
Niklaus
Hard case, I think!
Thanks for your PHP script. What happens, if you run it without the
preliminary javascript UI?
The database query looks very complicated. I'm not realy an expert in
mysqli. But as far as I experienced that, "SELECT" expects a _comma
separated_ list of valid expressions before the "FROM" keyword. You have
blanks there, like "us.login user" and others. Are you shure about this?
mysqli_query() does not return error messages, so you have blanc pages if it failes,
I think, you should have a look to the Mysql manual...
Niklaus
Ashley Sheridan
2014-01-30 12:49:13 UTC
Permalink
Post by Adarsh Sharma
The one thing i doubts whether program control reaches to
ajaxex.php.Access_log says it is executing ajaxex.php. I tried to check
whether my program flow reaches to ajaxex.php by adding below lines in
//echo "Mysql Connected";
//echo "Value of users : $q";
before the select command but after clicking on Weekly Report nothing
happens :(
Seems debugging is very difficult than to fix. There is no error in
error_log as well.
Thanks
On Thu, Jan 30, 2014 at 4:55 PM, Adarsh Sharma
Post by Adarsh Sharma
There is no error in mysql queries i.e i told earlier if u opens the
*http://db11.app.com/project/ajaxex.php?q=133
<http://db11.app.com/project/ajaxex.php?q=133>*
you will get the complete report so no issues with ajaxex.php.
but i need the same after clicking on Weekly Report Command button
when i
Post by Adarsh Sharma
opened
*http://db11.app.com/project
<http://db11.app.com/project/ajaxex.php?q=133> and chooses one user.
*
Post by Adarsh Sharma
*Thanks*
Post by Adarsh Sharma
Post by Adarsh Sharma
PFA
Thanks
On Thu, Jan 30, 2014 at 3:57 PM, Adarsh Sharma
Post by Adarsh Sharma
Agreed Nikha. Valid point. See i tested by added one line in my
var users = document.getElementById('users').value;
var queryString = "?users=" + users ;
* document.write(users); *
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();
When i run it , it gives me exact value of the user which i
chooses.
Post by Adarsh Sharma
Post by Adarsh Sharma
If my
Post by Adarsh Sharma
Post by Adarsh Sharma
user variable is empty then my output should be blank. Also,
http:///db11.app.com/project/ajaxex.php?q=133
It the end of the above link , you can see the exact value of
user.
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Thanks
On Thu, Jan 30, 2014 at 3:50 PM, Domain nikha.org
Post by Adarsh Sharma
Post by Adarsh Sharma
<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");
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
}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>
<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
Post by Adarsh Sharma
Post by Adarsh Sharma
mail
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Thanks
On Thu, Jan 30, 2014 at 2:36 PM, Domain nikha.org
Post by Adarsh Sharma
Post by Adarsh Sharma
Hi,
I am using AJAX and php for creating a small UI that
retrieves
Post by Adarsh Sharma
Post by Adarsh Sharma
data
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
from
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
mysql upon clicking on one button. But i clicked on that
,
Post by Adarsh Sharma
Post by Adarsh Sharma
nothing
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
is
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
*-- index.html *
<html>
<head>
function week_report_fun(){
var ajaxRequest;
---
---
--
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();
}
</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>
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
</body></html>
*Access Log Output :-*
1.4.15.25 - - [30/Jan/2014:06:05:52 +0000] "GET
/project/ajaxex.php?q=133
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
HTTP/1.1" 200 5323 "http://db11.app.com/project/"
"Mozilla/5.0
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
(Macintosh;
Post by Adarsh Sharma
Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like
Gecko)
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Chrome/32.0.1700.102 Safari/537.36"
1.4.15.25 - - [30/Jan/2014:06:06:13 +0000] "GET
/project/ajaxex.php?q=133
Post by Adarsh Sharma
HTTP/1.1" 200 5323 "-" "Mozilla/5.0 (Macintosh; Intel Mac
OS X
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
10_9_1)
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/32.0.1700.102
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Safari/537.36"
Post by Adarsh Sharma
No errors in error.log.
Strange thing if i directly open below link in the
browser,
Post by Adarsh Sharma
Post by Adarsh Sharma
report
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
is
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
*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
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
why it
Post by Adarsh Sharma
Post by Adarsh Sharma
is
Post by Adarsh Sharma
not working as expected after clicking on button.Please
let me
Post by Adarsh Sharma
Post by Adarsh Sharma
know
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
if i
Post by Adarsh Sharma
Post by Adarsh Sharma
am
Post by Adarsh Sharma
missing something.
Thanks
Hi Adarsh!
Yes, you are missing something: The opening <script> tag in
your
Post by Adarsh Sharma
Post by Adarsh Sharma
html
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
head!
Post by Adarsh Sharma
Post by Adarsh Sharma
without that, your ajax code is simply ignored.
Hope it helps
Niklaus
OK!
Consider to give names to the <form> and the <select> tag.
<form name="selector">
<select name="user">
var users = document.selector.user.value
Actualy, your users variable is just empty, what is not an
error. So
Post by Adarsh Sharma
Post by Adarsh Sharma
you
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
have no error reported.
Niklaus
Hard case, I think!
Thanks for your PHP script. What happens, if you run it without the
preliminary javascript UI?
The database query looks very complicated. I'm not realy an expert
in
Post by Adarsh Sharma
Post by Adarsh Sharma
mysqli. But as far as I experienced that, "SELECT" expects a _comma
separated_ list of valid expressions before the "FROM" keyword. You
have
Post by Adarsh Sharma
Post by Adarsh Sharma
blanks there, like "us.login user" and others. Are you shure about
this?
Post by Adarsh Sharma
Post by Adarsh Sharma
mysqli_query() does not return error messages, so you have blanc
pages if
Post by Adarsh Sharma
Post by Adarsh Sharma
it failes,
I think, you should have a look to the Mysql manual...
Niklaus
As others have said, what does your browser report in the network/console bar? Can you see the ajax request actually being made?

Bear in mind that there are several different ways of making ajax requests for different browsers, so you might be using the wrong method for the browser you're using.

Also, please try not to top post.

Thanks,
Ash
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Stuart Dallas
2014-01-30 13:32:14 UTC
Permalink
Not sure if my last email made is through or not, so here it is again.

Your code does not contain an element with the ID (ajaxDiv) in to which you are trying to put the AJAX response.
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
var ajaxDisplay = document.getElementById('ajaxDiv');
Where is ajaxDiv in your code?

-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
Post by Adarsh Sharma
The one thing i doubts whether program control reaches to
ajaxex.php.Access_log says it is executing ajaxex.php. I tried to check
whether my program flow reaches to ajaxex.php by adding below lines in
//echo "Mysql Connected";
//echo "Value of users : $q";
before the select command but after clicking on Weekly Report nothing
happens :(
Seems debugging is very difficult than to fix. There is no error in
error_log as well.
Thanks
Post by Adarsh Sharma
There is no error in mysql queries i.e i told earlier if u opens the
*http://db11.app.com/project/ajaxex.php?q=133
<http://db11.app.com/project/ajaxex.php?q=133>*
you will get the complete report so no issues with ajaxex.php.
but i need the same after clicking on Weekly Report Command button when i
opened
*http://db11.app.com/project
<http://db11.app.com/project/ajaxex.php?q=133> and chooses one user. *
*Thanks*
Post by Adarsh Sharma
Post by Adarsh Sharma
PFA
Thanks
Post by Adarsh Sharma
var users = document.getElementById('users').value;
var queryString = "?users=" + users ;
* document.write(users); *
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();
When i run it , it gives me exact value of the user which i chooses.
If my
Post by Adarsh Sharma
Post by Adarsh Sharma
user variable is empty then my output should be blank. Also,
http:///db11.app.com/project/ajaxex.php?q=133
It the end of the above link , you can see the exact value of user.
Thanks
Post by Adarsh Sharma
Post by Adarsh Sharma
<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>
<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
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Thanks
Post by Adarsh Sharma
Post by Adarsh Sharma
Hi,
I am using AJAX and php for creating a small UI that retrieves
data
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
from
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
mysql upon clicking on one button. But i clicked on that ,
nothing
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
is
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
*-- index.html *
<html>
<head>
function week_report_fun(){
var ajaxRequest;
---
---
--
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();
}
</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>
*Access Log Output :-*
1.4.15.25 - - [30/Jan/2014:06:05:52 +0000] "GET
/project/ajaxex.php?q=133
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
HTTP/1.1" 200 5323 "http://db11.app.com/project/" "Mozilla/5.0
(Macintosh;
Post by Adarsh Sharma
Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/32.0.1700.102 Safari/537.36"
1.4.15.25 - - [30/Jan/2014:06:06:13 +0000] "GET
/project/ajaxex.php?q=133
Post by Adarsh Sharma
HTTP/1.1" 200 5323 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X
10_9_1)
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.102
Safari/537.36"
Post by Adarsh Sharma
No errors in error.log.
Strange thing if i directly open below link in the browser,
report
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
is
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
*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
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
why it
Post by Adarsh Sharma
Post by Adarsh Sharma
is
Post by Adarsh Sharma
not working as expected after clicking on button.Please let me
know
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
if i
Post by Adarsh Sharma
Post by Adarsh Sharma
am
Post by Adarsh Sharma
missing something.
Thanks
Hi Adarsh!
Yes, you are missing something: The opening <script> tag in your
html
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
head!
Post by Adarsh Sharma
Post by Adarsh Sharma
without that, your ajax code is simply ignored.
Hope it helps
Niklaus
OK!
Consider to give names to the <form> and the <select> tag.
<form name="selector">
<select name="user">
var users = document.selector.user.value
Actualy, your users variable is just empty, what is not an error. So
you
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
have no error reported.
Niklaus
Hard case, I think!
Thanks for your PHP script. What happens, if you run it without the
preliminary javascript UI?
The database query looks very complicated. I'm not realy an expert in
mysqli. But as far as I experienced that, "SELECT" expects a _comma
separated_ list of valid expressions before the "FROM" keyword. You have
blanks there, like "us.login user" and others. Are you shure about this?
mysqli_query() does not return error messages, so you have blanc pages if it failes,
I think, you should have a look to the Mysql manual...
Niklaus
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Stuart Dallas
2014-01-30 14:30:25 UTC
Permalink
Please familiarise yourself with the console in your browser. If you’re using Safari or Chrome there is a developer console built in, and if using Firefox I recommend installing Firebug. This error, and any others in your Javascript will be displayed in the console and this whole mailing list conversation could have been avoided.

-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
Thanks Stuart , issue is fixed. You got the root cause.
Reports are coming now.
Thanks
Hi Stuart,
Please check below , ajaxDiv is at the end :-
<html>
<head>
<center><h1> OTRS Analysis </h1>
<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;
}
}
}
// Create a function that will receive data
// sent from the server and will update
// div section in the same page.
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4 && ajaxRequest.status == 200){
var ajaxDisplay = document.getElementById('ajaxDiv');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}i
var users = document.getElementById('users').value;
var queryString = "?users=" + users ;
//document.write(users);
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">an</option>
<option value="168">ad</option>
<option value="78">sou</option>
</select>
<input type='button' onclick="week_report_fun()"
value='Weekly Report'/>
</form>
<div id='ajaxDiv'>Your result will display here</div>
</body>
</html>
Please let me know if anything else is required
Thanks
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Maciek Sokolewicz
2014-01-30 21:51:00 UTC
Permalink
Post by Stuart Dallas
Please familiarise yourself with the console in your browser. If you’re using Safari or Chrome there is a developer console built in, and if using Firefox I recommend installing Firebug. This error, and any others in your Javascript will be displayed in the console and this whole mailing list conversation could have been avoided.
-Stuart
Actually, firefox does have its own (quite good even) developer toolbox
included by default. Though I still prefer firebug :)

On a sidenote: I would suggest installing and using JQuery for all this
kind of work. It makes making an ajax request and binding it to various
places in your code / design a LOT easier.

- Tul
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Ashley Sheridan
2014-01-30 21:53:30 UTC
Permalink
Post by Maciek Sokolewicz
Post by Stuart Dallas
Please familiarise yourself with the console in your browser. If you’re using Safari or Chrome there is a developer console built in, and if using Firefox I recommend installing Firebug. This error, and any others in your Javascript will be displayed in the console and this whole mailing list conversation could have been avoided.
-Stuart
Actually, firefox does have its own (quite good even) developer toolbox
included by default. Though I still prefer firebug :)
On a sidenote: I would suggest installing and using JQuery for all this
kind of work. It makes making an ajax request and binding it to various
places in your code / design a LOT easier.
- Tul
+1 for jQuery, as it gets around the problem I highlighted earlier where
different browsers implement ajax in different ways. jQuery unifies
those methods into one call.
--
Thanks,
Ash
http://www.ashleysheridan.co.uk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Christoph Michael Becker
2014-01-31 00:01:42 UTC
Permalink
Post by Ashley Sheridan
Post by Maciek Sokolewicz
On a sidenote: I would suggest installing and using JQuery for all this
kind of work. It makes making an ajax request and binding it to various
places in your code / design a LOT easier.
+1 for jQuery, as it gets around the problem I highlighted earlier where
different browsers implement ajax in different ways. jQuery unifies
those methods into one call.
Um, the XMLHttpRequest object is rather ubiquitous nowadays, so there's
no need to fall back to ActiveX objects, unless support for IE 6 is
absolutely needed -- however, there are users who have JavaScript
disabled, so a pure HTML fallback is reasonable anyway. IMO, jQuery
doesn't really simplify Ajax requests, and particularly $.get() is
deceptive, because it doesn't offer an error parameter, so error
handling is easily overlooked.
--
Christoph M. Becker
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Domain nikha.org
2014-01-30 11:35:13 UTC
Permalink
Post by Adarsh Sharma
There is no error in mysql queries i.e i told earlier if u opens the below
*http://db11.app.com/project/ajaxex.php?q=133
<http://db11.app.com/project/ajaxex.php?q=133>*
you will get the complete report so no issues with ajaxex.php.
but i need the same after clicking on Weekly Report Command button when i
opened
*http://db11.app.com/project
<http://db11.app.com/project/ajaxex.php?q=133> and chooses one user.*
*Thanks*
Post by Adarsh Sharma
Post by Adarsh Sharma
PFA
Thanks
Post by Adarsh Sharma
var users = document.getElementById('users').value;
var queryString = "?users=" + users ;
* document.write(users); *
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();
When i run it , it gives me exact value of the user which i chooses.
If my
Post by Adarsh Sharma
Post by Adarsh Sharma
user variable is empty then my output should be blank. Also,
http:///db11.app.com/project/ajaxex.php?q=133
It the end of the above link , you can see the exact value of user.
Thanks
Post by Adarsh Sharma
Post by Adarsh Sharma
<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>
<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
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
Thanks
Post by Adarsh Sharma
Post by Adarsh Sharma
Hi,
I am using AJAX and php for creating a small UI that retrieves
data
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
from
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
mysql upon clicking on one button. But i clicked on that ,
nothing
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
is
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
*-- index.html *
<html>
<head>
function week_report_fun(){
var ajaxRequest;
---
---
--
ajaxRequest.open("GET","ajaxex.php?q="+users,true);
ajaxRequest.send();
}
</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>
*Access Log Output :-*
1.4.15.25 - - [30/Jan/2014:06:05:52 +0000] "GET
/project/ajaxex.php?q=133
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
HTTP/1.1" 200 5323 "http://db11.app.com/project/" "Mozilla/5.0
(Macintosh;
Post by Adarsh Sharma
Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/32.0.1700.102 Safari/537.36"
1.4.15.25 - - [30/Jan/2014:06:06:13 +0000] "GET
/project/ajaxex.php?q=133
Post by Adarsh Sharma
HTTP/1.1" 200 5323 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X
10_9_1)
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.102
Safari/537.36"
Post by Adarsh Sharma
No errors in error.log.
Strange thing if i directly open below link in the browser,
report
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
is
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
*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
Post by Adarsh Sharma
Post by Adarsh Sharma
is
Post by Adarsh Sharma
not working as expected after clicking on button.Please let me
know
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
if i
Post by Adarsh Sharma
Post by Adarsh Sharma
am
Post by Adarsh Sharma
missing something.
Thanks
Hi Adarsh!
Yes, you are missing something: The opening <script> tag in your
html
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
head!
Post by Adarsh Sharma
Post by Adarsh Sharma
without that, your ajax code is simply ignored.
Hope it helps
Niklaus
OK!
Consider to give names to the <form> and the <select> tag.
<form name="selector">
<select name="user">
var users = document.selector.user.value
Actualy, your users variable is just empty, what is not an error. So
you
Post by Adarsh Sharma
Post by Adarsh Sharma
Post by Adarsh Sharma
have no error reported.
Niklaus
Hard case, I think!
Thanks for your PHP script. What happens, if you run it without the
preliminary javascript UI?
The database query looks very complicated. I'm not realy an expert in
mysqli. But as far as I experienced that, "SELECT" expects a _comma
separated_ list of valid expressions before the "FROM" keyword. You have
blanks there, like "us.login user" and others. Are you shure about this?
mysqli_query() does not return error messages, so you have blanc pages if
it failes,
I think, you should have a look to the Mysql manual...
Niklaus
I'm sorry, I cannot test your site: DNS failure!
host reports: "Host db11.app.com not found: 3(NXDOMAIN)"
If ist works for You, the error must be on the ajax side. Personaly I was never using ajax. So: refer to the ajax Manual :-)
Thanks, Niklaus
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Loading...