HDFilmMaker2112 Posted July 17, 2011 Share Posted July 17, 2011 For some reason the AJAX output on this page is not working. <script type="text/javascript"> function requestObj() { var reqObj; var browser = navigator.appName; if(browser == "Microsoft Internet Explorer"){ reqObj = new ActiveXObject("Microsoft.XMLHTTP"); }else{ reqObj = new XMLHttpRequest(); } return reqObj; } var http = requestObj(); function sndReq(action,id) { http.open('get', 'second_credit.php?credit='+action+'&id='+id, true); http.onreadystatechange = handleResponse; http.send(null); } function handleResponse() { if(http.readyState == 4){ var response = http.responseText; document.getElementById("ajaxout").innerHTML = response; } } </script> $content.=' <form action="" method="post"> <p><label>Name Credit is Listed Under:</label> <input type="text" name="name" size="30" /></p> <p><label>E-Mail of Original Purchase:</label> <input type="text" name="email" size="32" /></p> <p><label>Original Credit Purchased:</label>'; $sql_credit="SELECT $tbl_name2.credit,$tbl_name.donor_id,$tbl_name2.film_number FROM $tbl_name JOIN $tbl_name2 USING (donor_id) WHERE $tbl_name.username='$myusername' AND $tbl_name.password='$mypassword'"; $result_credit=mysql_query($sql_credit) or die(mysql_error()); $menu_generate=""; while($credit_rows=mysql_fetch_array($result_credit)){ extract($credit_rows); $menu_generate.='<option value="'.$credit.'-'.$film_number.'" >'.ucwords($credit).' - Film # '.$film_number.'</option>'."\n"; } $id=$_GET['donor_id']; $content.="<select name=\"credit\" onchange=\"sndReq(this.value,$id);\">"; $content.='<option value="">Select Credit</option>'."\n"; $content.=$menu_generate; $content.="</select>"; $content.='<p><label>Second Credit to Purchase:</label> <span id="ajaxout"></span></p>'; $content.='<p><input type="submit" value="Submit" name="Submit" /></p> </form> '; When I check the page called by ajax (second_credit.php), it loads properly. So the issue with the ajax call or the display. Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted July 17, 2011 Share Posted July 17, 2011 where are you actually output any content in your php page being called? Quote Link to comment Share on other sites More sharing options...
HDFilmMaker2112 Posted July 18, 2011 Author Share Posted July 18, 2011 In index.php... index.php is essentially the layout and everything else is generated separately and then included. Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted July 18, 2011 Share Posted July 18, 2011 I'm talking about your second_credit.php page. From the code that you have there, you aren't actually outputting anything on that page, so your response text will not return anything. Quote Link to comment Share on other sites More sharing options...
HDFilmMaker2112 Posted July 18, 2011 Author Share Posted July 18, 2011 I'm talking about your second_credit.php page. From the code that you have there, you aren't actually outputting anything on that page, so your response text will not return anything. ? I didn't even include my second_credit.php page. That's here: <?php session_start(); $myusername=$_SESSION['myusername2']; $mypassword=$_SESSION['mypassword2']; require_once 'db_select.php'; $credit=$_GET['credit']; $credit=explode('-',$credit); $credit=$credit[0]; $id=$_GET['id']; $sql_films="SELECT $tbl_name4.position,$tbl_name4.film_number FROM $tbl_name4 LEFT JOIN $tbl_name2 ON $tbl_name4.item_id=$tbl_name2.item_id LEFT JOIN $tbl_name ON $tbl_name.donor_id=$tbl_name2.donor_id AND $tbl_name.donor_id='$id' WHERE $tbl_name4.position='$credit' AND $tbl_name2.item_id IS NULL"; $result_films=mysql_query($sql_films) or die(mysql_error()); $select.='<select name="new_credit">'."\n"; $select.='<option value="">Select Credit</option>'."\n"; while($row_films=mysql_fetch_array($result_films)){ extract($row_films); $select.='<option value="'.$position.'-'.$film_number.'" >'.ucwords($position).' - Film # '.$film_number.'</option>'."\n"; } $select.='</select> '; echo $select; ?> The page I posted in my first post is credit.php which contains the HTML where the AJAX is supposed to print out. I didn't include second_credit.php because I didn't think it was really relative to the situation. As you can see here: http://www.makethemoviehappen.com/second_credit.php?credit=gaffer&id=2 second_credit.php works fine. Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted July 18, 2011 Share Posted July 18, 2011 would have been nice to know that the first php code that you posted was from index.php, you never specified that. Have you debugged your AJAX with alerts to try and find an error in the AJAX code? the second_credit.php will of course be important here, its where you are sending your information via AJAX! Quote Link to comment Share on other sites More sharing options...
HDFilmMaker2112 Posted July 18, 2011 Author Share Posted July 18, 2011 Have you debugged your AJAX with alerts to try and find an error in the AJAX code? I would do that how? I barely use Javascript, so I have no idea how to do that. Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted July 18, 2011 Share Posted July 18, 2011 I would use a different format of creating the xmlhttpreponse etc. refer here Once you have done this, if you are still having issues, post your new code and I will help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.