matheusryndack Posted January 18, 2015 Share Posted January 18, 2015 Hi everybody! I am trying to build a module that will use AJAX. I am using PS1.6 I have a php file that will return a XML with the data to be displayed on the page. But when I put my php file somewhere in my modules folder, I get a 404 error when trying to access it. Just for testing I put the file on website root and it worked perfectly. For example: I have this file: https://www.mydomain.com.br/modules/mymodule/calcularfrete.php (It returns 404). https://www.mydomain.com.br/calcularfrete.php (It returns the XML correctly). The files are in the server, I triple checked. It is not a .access problem, because I temporarily deleted the .htaccess file and I still get 404 erros. I guess this is a protection from prestashop, but I can't figure out how to do in a better way or use this way. Does anybody have any idea for me? Thanks! Matheus (from Brazil) Link to comment Share on other sites More sharing options...
vekia Posted January 18, 2015 Share Posted January 18, 2015 it can be a matter of permissions to file. please make sure that your .php file has got proper permission (each hosting can use little different values of chmod) check, for example, permissions for file index.php located in root directory of your prestashop. grant the same permissions to your .php file. Link to comment Share on other sites More sharing options...
El Patron Posted January 18, 2015 Share Posted January 18, 2015 please provide code that you are using to access the xml file in your module. Link to comment Share on other sites More sharing options...
matheusryndack Posted January 18, 2015 Author Share Posted January 18, 2015 (edited) Hello! Thanks for the answers! The permissions are all 644. Here is the code: function CalcularFrete(){ var cep = document.getElementById("cep").value; calculando = "<h4>Calculando.. Aguarde</h4>"; document.getElementById("resultado_frete_span").innerHTML = calculando; xmlhttp.onreadystatechange=function () { //essa função será chamada quando retornar. if (xmlhttp.readyState==4 && xmlhttp.status==200) { resposta = xmlhttp.responseText; parser=new DOMParser(); xmlDoc=parser.parseFromString(resposta,"text/xml"); tabela = "<table><tr><td>Serviço</td><td>Valor</td><td>Prazo</td></tr>"; numero_servicos = xmlDoc.getElementsByTagName("nome").length contador=0; for(i=0;i<numero_servicos;i++){ preco = xmlDoc.getElementsByTagName("preco")[i].childNodes[0].nodeValue; if(parseFloat(preco)>0){ //se o preço for zero passa para frente tabela += "<tr>"; tabela += "<td>"+xmlDoc.getElementsByTagName("nome")[i].childNodes[0].nodeValue+"</td>"; tabela += "<td>"+preco+"</td>"; tabela += "<td>"+xmlDoc.getElementsByTagName("prazo")[i].childNodes[0].nodeValue+"</td>"; tabela += "</tr>" contador++; } } if(contador==0) tabela = "<h4>Houve um erro ao calcular o frete. Por favor confira seu CEP e tente novamente. Caso percista por favor entre em contato conosco</tr><h4>"; else tabela += "</table><h4>Atenção: Esse valor é válido apenas para esse item e deverá ser confirmado no carrinho ao finalizar a compra. Os prazos informados são apenas os dos Correios e não incluem o tempo para postagem</h4>"; //fecha a tabela document.getElementById("resultado_frete_span").innerHTML = tabela; } } link = "https://www.mydomain.com.br/modules/mymodule/calcularfrete.php?"; link += "cep="+cep+"&"; link += "peso="+document.getElementById("peso").value+"&"; link += "vd="+document.getElementById("vd").value+"&"; //montamos o link link += "quantidade="+document.getElementById("quantidade").value; //montamos o link xmlhttp.open("GET",link,true); //mandamos a localização http xmlhttp.send(); } But I can't even access this file by browser. Thank you! Edited January 18, 2015 by matheusryndack (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted January 18, 2015 Share Posted January 18, 2015 are you able to open other files, for exmaple: domain.com/modules/homeslider/ajax_homeslider.php ? Link to comment Share on other sites More sharing options...
matheusryndack Posted January 18, 2015 Author Share Posted January 18, 2015 are you able to open other files, for exmaple: domain.com/modules/homeslider/ajax_homeslider.php ? Yes, I can open this file and I don't get a 404 error. Thank you Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now