Re: Re: PHP output fails from AJAX call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

>>>>>>> var ajaxDisplay = document.getElementById('ajaxDiv');

Where is ajaxDiv in your code?

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

On 30 Jan 2014, at 11:35, Adarsh Sharma <eddy.adarsh@xxxxxxxxx> wrote:

> 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
> 
> 
> On Thu, Jan 30, 2014 at 4:55 PM, Adarsh Sharma <eddy.adarsh@xxxxxxxxx>wrote:
> 
>> 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*
>> 
>> 
>> On Thu, Jan 30, 2014 at 4:45 PM, Domain nikha.org <mail@xxxxxxxxx> wrote:
>> 
>>> Adarsh Sharma am Donnerstag, 30. Januar 2014 - 11:36:
>>>> PFA
>>>> 
>>>> Thanks
>>>> 
>>>> 
>>>> On Thu, Jan 30, 2014 at 3:57 PM, Adarsh Sharma <eddy.adarsh@xxxxxxxxx
>>>> wrote:
>>>> 
>>>>> 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
>>>>> 
>>>>> 
>>>>> 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>
>>>>>>> <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
>>>>>>> 
>>>>>>> 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();
>>>>>>>>> }
>>>>>>>>> 
>>>>>>>>> </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
>>>>>>>>> 
>>>>>>>> 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
>>>>>> 
>>> 
>>> 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






[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux