Wednesday, 15 May 2013

php - XMLHttpRequest not working with Chrome -



php - XMLHttpRequest not working with Chrome -

i have code, simple update "cupom" "0" "1", isnt working chrome, firefox work, help/advice welcome.

var req; function val_impressao_js(cpf) { if(window.xmlhttprequest) { req = new xmlhttprequest(); } else if(window.activexobject) { req = new activexobject("microsoft.xmlhttp"); } var url = "val_impressao.php?cpf="+cpf; req.open("get", url, true); req.onreadystatechange = function() { if(req.readystate == 4 && req.status == 200) { window.print(); } } req.send(null); }

val_impressao.php

require "arqinc/conexao.php"; require "arqinc/funcoesbd.php"; $cpf=$_get['cpf']; $query=mysql_query("update cadcoo set cupom=1 cpf_cadpessoafisica=$cpf , cupom=0");

and way, part isnt working too, not print page.

if(req.readystate == 4 && req.status == 200) { window.print(); }

i suggest next script, can work ie7 , modern browsers.

window.onload = initall; var xhr = false; function initall() { document.getelementbyid("requestxml").onclick = makerequest; } function makerequest() { if (window.xmlhttprequest) { xhr = new xmlhttprequest(); } else { if (window.activexobject) { seek { xhr = new activexobject("microsoft.xmlhttp"); } grab (e) { } } } if (xhr) { xhr.onreadystatechange = showcontents; xhr.open("get", "us-states.xml", true); xhr.send(null); } else { document.getelementbyid("updatearea").innerhtml = "sorry, couldn't create xmlhttprequest"; } homecoming false; } function showcontents() { if (xhr.readystate == 4) { if (xhr.status == 200) { var outmsg = xhr.responsetext; } else { var outmsg = "there problem request " + xhr.status; } document.getelementbyid("updatearea").innerhtml = outmsg; } }

php javascript ajax google-chrome

No comments:

Post a Comment