envexlabs Posted July 26, 2007 Share Posted July 26, 2007 Hey, I have an image upload script that i'm trying to execute via AJAX, but my browser is giving me this error in the JS Console: Warning: Form contains enctype=multipart/form-data, but does not contain method=post. Submitting normally with method=GET and no enctype instead. Source File: http://*********.com/store.php?store_id=1 Line: 0 my ajax.js file: //AJAX POST var http_request = false; function makePOSTRequest(url, parameters) { 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 = alertContents; http_request.open('POST', url, true); 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(parameters); slide_product(); } function alertContents() { if (http_request.readyState == 4) { if (http_request.status == 200) { result = http_request.responseText; document.getElementById('store_contents').innerHTML = result; } else { alert('There was a problem with the request.'); } } } function get(obj) { var poststr = "pname=" + encodeURI( document.getElementById("pname").value ) + "&price=" + encodeURI( document.getElementById("price").value ) + "&desc=" + encodeURI( document.getElementById("desc").value ) + "&cat_id=" + encodeURI( document.getElementById("cat_id").value ) + "&pic=" + encodeURI( document.getElementById("pic").value ) + "&store_id=" + encodeURI( document.getElementById("store_id").value ); makePOSTRequest('inc/ajax/add_product.php', poststr); alert(poststr); } Does anyone know how to fix this? Link to comment https://forums.phpfreaks.com/topic/61922-using-post-but-browser-reverting-to-get/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.