Re: Re: PHP output fails from AJAX call
| From: | Stuart Dallas | Date: | Thu, 30 Jan 2014 10:32:22 +0000 |
| Subject: | Re: Re: PHP output fails from AJAX call | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-322772@lists.php.net to get a copy of this message | ||
>> 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>
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/