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

How to set up charset (encoding) in HttpConnection

New Here ,
Oct 24, 2019 Oct 24, 2019

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';
 
TOPICS
How to , Problem or error , Scripting

Views

484

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

This code is for Illustrator 

Likes

Translate

Translate

Report

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

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. 

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

My script is based on this:

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

Likes

Translate

Translate

Report

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