1

So I need to pass to my script an array of such arrays [name, width, height] and be capable to iterate through such array. In what format, how should my server response and how to request(my server can response on any Http and tcp request in any required form.) So I am in search for easiest in implementing on js side. But I can not use any special JS libs like Jquery. (as I said server can form any kind of TCP and HTTP response.)

So how should look my response to pass such array of arrays to JS and how to read it using JS?

2 Answers 2

2

Use JSONP.

Sign up to request clarification or add additional context in comments.

2 Comments

That's really only for when you're hindered by the same-origin policy.
Why so? AFAIK, HTTP requests for JS files are a little faster than Ajax requests (don't know why, that's what it says in High Performance JavaScript, by Nicholas C. Zakas), and parse times are better with a script tag, than eval and probably JSON.parse on response body. There are some downsides compared to Ajax, like the ability to set/read headers, or status codes, but maybe he doesn't need this yet.
2

Just return JSON

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.