Greywacke Posted March 31, 2010 Share Posted March 31, 2010 hi there,i am currently experiencing a message string being dropped via ajax post.here follows the function that prepares the makes the request, followed by the code that prepares the data and requests it being sent. var ajaxloading = 0;function makeRequest(method, url, parameters) { var http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { // set type accordingly to anticipated content type http_request.overrideMimeType('text/xml'); //http_request.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Cannot create XMLHTTP instance'); return false; } http_request.onreadystatechange = function() { alertContents(http_request); } url += (method=="GET")?parameters:""; http_request.open(method, url, true); if (method == "POST") { http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http_request.setRequestHeader("Content-length", parameters.length); http_request.setRequestHeader("Connection", "close"); } http_request.send((method=="GET")?null:parameters); ajaxloading++;} var poststr = "textarea_transactionmessage=" + escape(document.form_transactions. textarea_transactionmessage.value);var s = document.form_transactions.menu_transactiontype. options[document.form_transactions.menu_transactiontype.selectedIndex].value;var f = document.form_transactions.menu_fromtimestamp. options[document.form_transactions.menu_fromtimestamp.selectedIndex].value;var t = document.form_transactions.menu_totimestamp. options[document.form_transactions.menu_totimestamp.selectedIndex].value;makeRequest("POST", "scripts/ajax_signup.php?q=1&s="+s+"&f="+f+"&t="+t, poststr); thus in theory, if the message value is "test message", and sending it to the handler (ajax_signup.php) it should retrieve it in the following code. // get statement message$message = $_POST["textarea_transactionmessage"];// insert statement message$body = str_replace("%MESSAGE%",$message,$body); yet the mails i receive have a blank message inserted into the paragraph that is originally "<p>%MESSAGE%</p>" 0ocan anybody perhaps see what i do not see here? the value is retrieved successfully and posted as "textarea_transactionmessage=test%20message". the querystring values s, f & t are successfully retrieved via $_GET. Link to comment Share on other sites More sharing options...
justsomeguy Posted March 31, 2010 Share Posted March 31, 2010 Use Firebug or something to look at the request going out, make sure the post data and headers are correct. Make sure to check that the content length header matches the length of the data. Link to comment Share on other sites More sharing options...
Greywacke Posted April 1, 2010 Author Share Posted April 1, 2010 nevermind, i seem to have this issue resolved now i believe it was due to utf8 encoding as result of the delivering page and form etc all being utf8, this was resolved as soon as i used utf8_decode on the string the problem was really php - but is resolved now Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.