/ Published in: JavaScript
ajax
Expand |
Embed | Plain Text
function ajaxRequest(target, method, params, callback, graph) { var xmlhttp=false; if (!xmlhttp && typeof XMLHttpRequest!='undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp=false; } } if (!xmlhttp && window.createRequest) { try { xmlhttp = window.createRequest(); } catch (e) { xmlhttp=false; } } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { window[callback](xmlhttp.responseText); } else if (xmlhttp.status.toString().substring(0,1) == 3 || xmlhttp.status.toString().substring(0,1) == 4) { message('Die Anfrage lieferte kein Resultat.', true); } }; xmlhttp.open(method, target, true); if ((method == 'POST' || method == 'post') && params.length > 0) { xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-length", params.length); xmlhttp.setRequestHeader("Connection", "close"); xmlhttp.send(params); } else { xmlhttp.send(null); } }
You need to login to post a comment.
