Epson TM-T20II-i ePOS-Print XML Users Manual - Page 51
Reception of Print Result, A print error occurred
![]() |
View all Epson TM-T20II-i manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 51 highlights
Chapter 3 Programming Guide (XML Print Service) Reception of Print Result Set a callback function using the response root element (p. 63) to receive print results. The following information is obtained: ❏ Print result ❏ Error code ❏ Printer status ❏ Printer's battery status The printer status can be obtained when communication with the printer is possible. Refer to the following program. For the details about how to program a callback function in detail, refer to Error handling (p.52). TITLE function sendDocument() { //Create a print document var request = ''; request += ''; 3 request += ''; request += 'Hello, World! '; request += ''; request += ''; //Create a SOAP envelop var soap = '' + ' ' + request + ''; //Create an XMLHttpRequest object var xhr = new XMLHttpRequest(); //Set the end point address var url = 'http://192.168.192.168/cgi-bin/epos/ service.cgi?devid=local_printer&timeout=10000'; //Open an XMLHttpRequest object 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 callback function xhr.onreadystatechange = function () { if (xhr.readyState == 4) { if (xhr.status == 200) { //Obtain the response root element var res = xhr.responseXML; var success = res.getElementsByTagName('response')[0].getAttribute('success'); //When the printing is not successful, display a message if (!/^(1|true)$/.test(success)) { alert('A print error occurred'); } } } // Send print document xhr.send(soap); } Callback function for print result reception 51
![](/manual_guide/products/epson-p60ii-eposprint-xml-user-s-manual-744bcec/51.png)