Reputation: 3858
I have been working some weeks on a python program which uses html, javascript and ajax. Everything was working perfect on IE but when I run my program on other browsers, it does not work. Since then, I have been trying to know why but I still dont know.
I have made some proves making the simpliest function but still does not work. I add alert(xml.responseText);
in all my functions to see what the Ajax function returns. On IE returns the exact answer that I want, but on other browsers the alert is empty.
I have made some other python programs with ajax and they all work very well. The only difference that I can notice is that this program (the one that does not work) has the javascript and the ajax functions inside the python file, in order to make a dinamic function.
So, instead of having a file.js
with all the ajax functions, I have a <script>
tag inside my pythonFile.py
as in HTML.
Does anyone know if having all my functions inside the python file can affect something on other browsers but not in IE8?
here is my AJAX object:
<script type="text/javascript">
var xmlhttp;
var request = true;
function GetXmlHttpObject() {
try {
request = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
request = new ActiveXObject("Msxml12.XMLHTTP");
} catch (othermicrosoft) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
return false; //or null
}
}
}
if (!request)
alert ("Error initializing XMLHTTPRequest!");
return request;
}
function respuestas(idEvaluacion){
var prueba = "ESTA ES UNA PRUEBA";
url = 'evaluacionDesempenoBD.py?prueba=' + prueba;
xmlhttp = GetXmlHttpObject();
if (!xmlhttp) {
alert ("Browser does not support HTTP Request");
return;
}
var xml = xmlhttp;
xmlhttp.onreadystatechange = function (idEvaluacion) {
if (xml.readyState == 4){
alert(xml.responseText);
}
};
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
return true;
}
</script>
Upvotes: 0
Views: 139
Reputation: 328574
No - since the browser never sees the Python script - only the output but that is a byte stream and isn't "tainted" in any way, no matter which (script) language created it.
So the problem must be elsewhere. The usual approach is to have a look into the JavaScript console of the browser in question and check for any error messages.
If that doesn't help, start to look at the network protocol where you can see all the requests and responses. That might give you an idea.
Also alert()
is a really bad "tool" for debugging. Try one of the logging frameworks for JavaScript: http://blog.pdark.de/2011/11/24/logging-from-javascript/
Upvotes: 1