tarun Posted June 17, 2007 Share Posted June 17, 2007 I Have A PHP Upload Script It Works Fine When Uploading Using A Form But I Doesn't Work When Creating An AJAX Post Why...? Is What I Would Like To Know And If Possible How Can I Correct It I Do Not Which To Display The Contents Of The PHP Script But The AJAX/HTML Is Fine <script> var page = "upload.php"; function postAJAX(url, query, target) { var status = false; var contentType = "application/x-www-form-urlencoded; charset=UTF-8"; // Native XMLHttpRequest object if (window.XMLHttpRequest) { request = new XMLHttpRequest(); request.onreadystatechange = function() {ajaxDone(target);}; request.open("post", url, true); request.setRequestHeader("Content-Type", contentType); request.send(query); status = true; // ActiveX XMLHttpRequest object } else if (window.ActiveXObject) { request = new ActiveXObject("Microsoft.XMLHTTP"); if (request) { request.onreadystatechange = function() {ajaxDone(target);}; request.open("post", url, true); request.setRequestHeader("Content-Type", contentType); request.send(query); status = true; } } return status; } function ajaxDone(target) { if (request.readyState == 4) { if (request.status == 200 || req.status == 304) { results = request.responseText; document.getElementById(target).innerHTML = results; } else { document.getElementById(target).innerHTML="Ajax Error:\n" + req.statusText; } } } </script> 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.