limitphp Posted May 14, 2009 Share Posted May 14, 2009 Its loading the correct page in the correct target_div, but the form data is not being sent. Can someone help me? Here's my code: <form name='frmInbox$messageID' method='post' action='myaccount_ajx_inbox_reply.php' onsubmit='return false'> <input type='hidden' name='to_userID' value='$to_userID'> <textarea NAME='message' style='overflow-x: hidden; display: block;' cols='65' rows='10'></textarea> </textarea> <input type='submit' value='Submit' onclick='check_message($messageID)'> </form> here's check_message(): function check_message(messageID){ ajx_post('message'+messageID, 'myaccount_ajx_inbox_reply.php', ''); } here's my ajx function: function ajx_post(target_div, file, params) { var MyHttpRequest = false; if (target_div.indexOf("voteCount")>=0) var MyHttpLoading = ''; else var MyHttpLoading = '<p>Loading...</p>'; // or use an animated gif instead: var MyHttpLoading = '<img src="loading.gif" border="0" alt="running" />'; var ErrorMSG = 'Sorry - No XMLHTTP support in your browser, try firefox or internet explorer instead.'; if(window.XMLHttpRequest) // client use Firefox, Opera etc - Non Microsoft product { try { MyHttpRequest = new XMLHttpRequest(); } catch(e) { MyHttpRequest = false; } } else if(window.ActiveXObject) // client use Internet Explorer { try { MyHttpRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { MyHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { MyHttpRequest = false; } } } else { MyHttpRequest = false; } if(MyHttpRequest) // browser supports httprequest { var random = Math.random() * Date.parse(new Date()); // make a random string to prevent caching var query_string = url_encode('?rand=' + random + params); MyHttpRequest.open("POST", file, true); // <-- run the httprequest using GET //Send the proper header information along with the request MyHttpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); MyHttpRequest.setRequestHeader("Content-length", query_string.length); MyHttpRequest.setRequestHeader("Connection", "close"); // handle the httprequest MyHttpRequest.onreadystatechange = function () { if(MyHttpRequest.readyState == 4) // done and responded { document.getElementById(target_div).innerHTML = MyHttpRequest.responseText; // display result } else { document.getElementById(target_div).innerHTML = MyHttpLoading; // still working } } MyHttpRequest.send(query_string); } else { document.getElementById(target_div).innerHTML = ErrorMSG; // the browser was unable to create a httprequest } } Quote Link to comment Share on other sites More sharing options...
limitphp Posted May 14, 2009 Author Share Posted May 14, 2009 AH HA!!!!! You have to put the value of everything you are posting in the httprequest.send() well...that sort of defeats the purpose of the POST method..... if you stick a & it messes up the value...and doesn't show up. 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.