Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to set up charset (encoding) in HttpConnection

New Here ,
Oct 24, 2019 Oct 24, 2019
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';
 
TOPICS
How to , Problem or error , Scripting
739
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 24, 2019 Oct 24, 2019

Why all the script += statements? What are you trying to do?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 24, 2019 Oct 24, 2019

This code is for Illustrator 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 24, 2019 Oct 24, 2019

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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 25, 2019 Oct 25, 2019
LATEST

My script is based on this:

https://gist.github.com/mericson/6509997

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines