var http_request_category = false; var MySpaneNameCategory = "myspan_category"; function makePOSTRequestCategory(url, parameters) { http_request_category = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request_category = new XMLHttpRequest(); if (http_request_category.overrideMimeType) { // set type accordingly to anticipated content type //http_request_category.overrideMimeType('text/xml'); http_request_category.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { http_request_category = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request_category = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request_category) { alert('Cannot create XMLHTTP instance'); return false; } var contentType = "application/x-www-form-urlencoded; multipart/form-data;"; http_request_category.onreadystatechange = alertCategory; http_request_category.open('POST', url, true); http_request_category.setRequestHeader("Content-type", contentType); http_request_category.setRequestHeader("Content-length", parameters.length); http_request_category.setRequestHeader("Connection", "close"); http_request_category.send(parameters); } function alertCategory() { if (http_request_category.readyState == 4) { if (http_request_category.status == 200) { //alert(http_request_category.responseText); result = http_request_category.responseText; document.getElementById(MySpaneNameCategory).innerHTML = result; } else { alert('There was a problem with the request no 1.'); } } } function getCategory(category_id,task,file) { MySpaneNameCategory = "myspan_category"; if (task!="default") { document.getElementById(MySpaneNameCategory).innerHTML = 'wczytwanie danych kategorii..'; } var poststr = ""; poststr = poststr + "task=" + task; poststr = poststr + "&category_id=" + category_id; if (task=="delete") { poststr = poststr + "&file=" + file; } if (task=="default") { poststr = poststr + "&file=" + file; } makePOSTRequestCategory("/scripts/forms/category/category.php", poststr); }