How to make http request using javascript in vxml? (generally src contains link of any xml file for data element . but in my case it is not necessary to be a xml file. so i think i can't use data element here.)
-
At first, vxml's script(ECMAScript) can't make TCP/IP connection. If you wish http request in vxml, you can use data element or subdialog element. Parhaps another solution is none. – Bladean Mericle Sep 20 '13 at 09:16
-
You are limited in what you can do as far as http requests in vxml. But if you provide the larger requirement around your wanting to do this there probably is a solution. For example, what kind of document are you retrieving and what type of processing do you need to perform on it? What type of web technology are you using to create your vxml, or are they all static xml? – Kevin Junghans Sep 20 '13 at 12:45
1 Answers
There is nothing in pure ECMAScript supported by VXML browsers (that I know of -- unless someone has significantly extended their browser from the standard) that allows anything like what you seem to be asking for, like XMLHttpRequest for regular web AJAX requests. However, as Kevin Junghans mentioned, you could make use of the element to fetch a document which is expected to be XML. Some browsers may have extensions to the VXML standard that allow you to specify the file type coming back, letting you pick either XML or JSON.
However, a more generalized solution, if you don't know beforehand what format the fetched document will be in, may be to write a wrapper XML web service which in turn requests the desired document, and wraps it in XML.
e.g.
<var name="docURI" expr="'http://someserver/some/doc.json'" />
<data name="documentContents" src="myservice.xml.php" namelist="docURI" />
and write myservice.xml.php to return something like
<?xml version="1.0"?>
<documentWrapper>content from doc.json</documentWrapper>

- 15,563
- 19
- 81
- 112

- 1
- 2