You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Ted Hickox <me...@gmail.com> on 2015/07/15 18:12:21 UTC

[users@httpd] XMLHTTPRequest

I'm trying to master AJAX.  This is my javascript code:

var Data_Display
var My_Data

function Setup() {

     My_Data = new XMLHttpRequest();
     My_Data.open("GET","
http://localhost:8080/exist/rest/db/apps/HTML_Student/SVG_Data.xq");
 My_Data.send();
 document.getElementById("Information").value = My_Data.responseXML;

}

This is my XML

<xml>
<svg>
<svg_data>100</svg_data>
</svg>
</xml>

This is my XQuery

xquery version "3.0";
for $Data in doc("Database_Example.xml")/xml/svg/svg_data
where $Data = 100
return $Data

When I open my webpage, nothing appears in the textbox.  Am I doing
something wrong?

Re: [users@httpd] XMLHTTPRequest

Posted by Marat Khalili <mk...@rqc.ru>.
Hi Ted,

Your send() call is asynchronous, meaning you don't receive results immediately. Register onload event listener and wait; you can easily find proper usage patterns in the net.

Also, it is not productive to ask questions without looking at server logs, JavaScript console and LiveHttpHeaders first. Many things could go wrong with your setup and we would not even know it.
-- 

With Best Regards,
Marat Khalili

On July 15, 2015 7:12:21 PM GMT+03:00, Ted Hickox <me...@gmail.com> wrote:
>I'm trying to master AJAX.  This is my javascript code:
>
>var Data_Display
>var My_Data
>
>function Setup() {
>
>     My_Data = new XMLHttpRequest();
>     My_Data.open("GET","
>http://localhost:8080/exist/rest/db/apps/HTML_Student/SVG_Data.xq");
> My_Data.send();
> document.getElementById("Information").value = My_Data.responseXML;
>
>}
>
>This is my XML
>
><xml>
><svg>
><svg_data>100</svg_data>
></svg>
></xml>
>
>This is my XQuery
>
>xquery version "3.0";
>for $Data in doc("Database_Example.xml")/xml/svg/svg_data
>where $Data = 100
>return $Data
>
>When I open my webpage, nothing appears in the textbox.  Am I doing
>something wrong?