General XMetaL Discussion
XMetaL Community Forum › General XMetaL Discussion › Asynchronous JavaScript?
-
jodekirk December 16, 2015 at 8:21 pm
Asynchronous JavaScript?
December 16, 2015 at 8:21 pmParticipants 4Replies 5Last Activity 7 years, 3 months agoI have JavaScript code accessing a web service, but it locks up XMetaL until the request finishes. How do we use asynchronous JavaScript calls that do not lock up XMetaL?
I have code similar to this:
…
var entid = 40163132;
var params = “[” + entid + “]”;
var ASYNC = true;
xmlhttp = new ActiveXObject(“MSXML2.XMLHTTP.6.0”); // code for IE6, IE5 or XMetaL
xmlhttp.open(“POST”, url, !ASYNC);
xmlhttp.setRequestHeader(“content-type”, “application/json”);
xmlhttp.send(params);
var response = xmlhttp.responseText;
var json = JSON.parse(response);
…sajoss January 8, 2016 at 10:56 am
Reply to: Asynchronous JavaScript?
January 8, 2016 at 10:56 amxmlhttp = new ActiveXObject(“MSXML2.XMLHTTP.6.0”); // code for IE6, IE5 or XMetaL
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
//async code in here
var response = xmlhttp.responseText;
var json = JSON.parse(response);
}
}
xmlhttp.open(“POST”, url, true);
xmlhttp.setRequestHeader(“content-type”, “application/json”);
xmlhttp.send(params);this works for me but you may want to consider timeouts etc. if you cannot reach the server and also handling some other status although you will get no headers in Xmetal until you reach a readystate of 4 afaik. (I have been having a long painful journey with http requests in Xmetal)
jodekirk January 12, 2016 at 7:29 pm
Reply to: Asynchronous JavaScript?
January 12, 2016 at 7:29 pmI get an error on this line. How do you get past it?
[code]if (xmlhttp.readyState == 4)[/code]
0x800a138f – Microsoft JScript runtime error: 'xmlhttp.readyState' is null or not an objectAny ideas?
My code works fine if I change the async parameter to false. How do you do this in XMetaL with async set to true?jodekirk January 12, 2016 at 8:12 pm
Reply to: Asynchronous JavaScript?
January 12, 2016 at 8:12 pmI figured it out. Thanks! I set the xmlhttp to null at the bottom of the function which broke the async code. It works now. Thanks!
Angelael March 18, 2016 at 5:57 pm
Reply to: Asynchronous JavaScript?
March 18, 2016 at 5:57 pmADMIN –
Any potential for integrating a chrome-like open source kit and updating this component to the modern web from within the application?Derek Read March 21, 2016 at 6:35 pm
Reply to: Asynchronous JavaScript?
March 21, 2016 at 6:35 pm@Angelael: please contact XMetaL Support to make a feature request. Include as much information about your goals as possible so we can figure out why you think you need what you are requesting (there are often multiple ways to accomplish the same result). In other words, a request like: “our users need to be able to do X” is more useful than “please add support for Y”.
Keep in mind that if what you ask for can already be accomplished it is unlikely a new feature would be implemented.
-
AuthorPosts
- You must be logged in to reply to this topic.