Copy link to clipboard
Copied
I try to connect to web in script from Illustrator. How to set up charset (encoding) in HttpConnection?
This code does not working:
var script = '';
script += 'if ( !ExternalObject.webaccesslib )\n';
script +=
' ExternalObject.webaccesslib = new ExternalObject(\'lib:webaccesslib\');\n';
script += 'var response = null;\n';
script += 'var retry = true;\n';
script += 'while (retry) {\n';
script += ' var http = new HttpConnection(\'' + url + '\') ; \n';
script += ' http.mime = "application/x-www-form-urlencoded; charset=UTF-8"; \n';
script += ' http.requestheaders = ["charset", "UTF-8"];\n';
script += ' http.timeout = ' + httpTimeout + ';\n';
script += ' http.execute() ;\n';
script += ' try{\n';
script += ' response = http.response;\n';
script += ' retry = false;\n';
script += ' } catch (e){\n';
script += ' BridgeTalk.bringToFront(\'bridge\');\n';
script +=
' if (!confirm(\'There was an error communicating with the server. Would you like to retry?\'))\n';
script += ' retry = false;\n';
script += ' }\n';
script += '}\n';
script += 'response;\n';
Copy link to clipboard
Copied
Why all the script += statements? What are you trying to do?
Copy link to clipboard
Copied
This code is for Illustrator
Copy link to clipboard
Copied
I still don't understand why you are converting all you code to a string by using: "script +=". The only time I've done that is to have a script rewrite a new script from that string. This was for the deco fill script that doesn't allow the creation of a UI.
Copy link to clipboard
Copied
My script is based on this: