Epson TM-T20II-i ePOS-Print XML Users Manual - Page 53
Checking the Printer Status, Programming Guide XML Print Service
View all Epson TM-T20II-i manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 53 highlights
Chapter 3 Programming Guide (XML Print Service) Checking the Printer Status To check the printer status without printing, send empty print data. Refer to the following program. //Set the end point address var url = 'http://192.168.192.168/cgi-bin/epos/service.cgi?devid=local_printer &timeout=10000'; //Create an empty print document to check the printer status var soap = ''; //Create an XMLHttpRequest object var xhr = new XMLHttpRequest(); // xhr.open('POST', url, true); // xhr.setRequestHeader('Content-Type', 'text/xml; charset=utf-8'); xhr.setRequestHeader('If-Modified-Since', 'Thu, 01 Jan 1970 00:00:00 GMT'); xhr.setRequestHeader('SOAPAction', '""'); //Set a response reception callback function for checking xhr.onreadystatechange = function () { if (xhr.readyState == 4){ if (xhr.status == 200){ var res = xhr.responseXML; var success = res.getElementsByTagName('response')[0].getAttribute('success'); if (!/^(1|true)$/.test(success)) { alert('Success'); } 3 } } }; //Send empty print data xhr.send(soap); 53