I don't see anything obviously wrong with your code, but here is a
snippet of my code which does the same thing and works fine.
Note I use RequestBuilder.GET and have a couple of extra error checks
- might help point to a problem.
==============
url = URL.encode(url);
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
try {
@SuppressWarnings("unused")
Request request = builder.sendRequest("", new RequestCallback()
{
public void onError(Request request, Throwable exception) {
fireErrorEvent("Couldn't retrieve info");
}
public void onResponseReceived(Request request, Response
response) {
if (200 == response.getStatusCode()) {
//200 means all ok, so do something with
response.getText()
}
else if (0 == response.getStatusCode()){
fireErrorEvent(response.getText());
}
else
{
fireErrorEvent("Couldn't retrieve data (" +
response.getStatusText() + response.getStatusCode() + ")");
}
}
});
}
catch (RequestException e) {
fireErrorEvent("Couldn't retrieve info");
}
==============
On Mar 1, 1:11 pm, mibtar <[email protected]> wrote:
> hi, i'm using requestbuilder to communicate with php.
>
> i used a XMLWriter to place the sql result in xml:
>
> $writer = new XMLWriter();
> $writer->openMemory();
> $writer->startDocument('1.0', 'UTF-8');
> $writer->setIndent(4);
> $writer->startElement("result");
> for($row = 0; $rowdata = mysql_fetch_array($result); $row++){
> $writer->startElement("row");
> $writer->writeAttribute("index", $row);
> for($col = 0; $col < count($rowdata)/2; $col++){
> $writer->startElement("column");
> $writer->writeAttribute("index", $col);
> $writer->text($rowdata[$col]);
> $writer->endElement();
> }
> $writer->endElement();
> }
> $writer->endElement();
> $writer->endDocument();
> echo $writer->outputMemory();
>
> when i view it in a browser it perfectly fine, this is the page source
> content:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <result>
> <row index="0">
> <column index="0">1</column>
> <column index="1">abc</column>
> <column index="2">123</column>
> </row>
> <row index="1">
> <column index="0">2</column>
> <column index="1">def</column>
> <column index="2">456</column>
> </row>
> <row index="2">
> <column index="0">3</column>
> <column index="1">ghi</column>
> <column index="2">789</column>
> </row>
> </result>
>
> it looks fine. but when i try to get the data using request builder
> and use Window.alert:
>
> RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
> script);
> builder.setHeader("Content-Type", "application/x-www-form-
> urlencoded");
> builder.sendRequest("", new RequestCallback() {
> public void onResponseReceived(Request request, Response response)
> {
> Window.alert(response.getText());
> }
>
> public void onError(Request request, Throwable exception) {
> Window.alert("Error: " + exception.toString());
> }
>
> });
>
> the output i get is:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <result/>
>
> any idea what happened to the content of the document?
>
> i even tried to make the script simple:
>
> $output = "";
> $output = $output . '<?xml version="1.0" encoding="UTF-8"?>';
> $output = $output . '<result>';
> for($row = 0; $rowdata = mysql_fetch_array($result); $row++){
> $output = $output . '<row index="' . $row .'">';
> for($col = 0; $col < count($rowdata)/2; $col++){
> $output = $output . '<column index="' . $col .'">';
> $output = $output . $rowdata[$col];
> $output = $output . '</column>';
> }
> $output = $output . '</row>';
> }
> $output = $output . '</result>';
> echo $output;
>
> i get the correct output in php but i still get the same empty
> document
> in the response
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.