21287 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1300 Views |
-
Rendering Content as XML for AJAX

31 December 2009 at 5:52am
I'm trying to create an AJAX image switcher for different Colored Product.
In my Page_Controller id added
if(Director::is_ajax() || $_GET["ajaxDebug"]) {
$this->isAjax = true;
}
else {
$this->isAjax = false;
}Then in my ColorProduct Page Controller I added:
function index() {
if($this->isAjax) {
return $this->renderWith("ColorProductXML");
}
else {
return Array();
}
}I then created a ColorProductXML tempalte and placed it in my root template directory
<?xml version="1.0" encoding="UTF-8"?>
<colorproduct>
<% control Colors %>
<color colorID="$StripColorName">
<name>$ColorName</name>
<hex>$ColorHex</hex>
<% control ToyImageClasss %>
<imagegroup imageName="$StripImageName">
<type>$ImageClass</type>
<% control ToyImages %>
<% if Type=="Normal" %>
<% control Attachment %>
<thumbnail>$SetWidth(60).URL</thumbnail>
<small>$SetWidth(460).URL</small>
<zoom>$SetWidth(920).URL</zoom>
<full>$URL</full>
<% end_control %>
<% end_if %>
<% if Type=="Blur" %>
<blur>$Attachment.URL</blur>
<% end_if %>
<% end_control %>
</imagegroup>
<% end_control %>
</color>
<% end_control %>
</colorproduct>When I access a ColorProduct page adding ?ajax=1 to the end of my URL I get nice XML document, and my jQuery call to that url also returns a document in the same format but I can't query the nodes. Firebug shows the Content-Type as text/html instead of application/xml. How do I force SS to return an XML content type?
-
Re: Rendering Content as XML for AJAX

31 December 2009 at 11:00am
After a few more fruitless hours of digging I decided to copy the contents of the page with ?ajax=1 variable added and paste it into a static xml file. When my jQuery script loads THAT file i notice when I dump it i see the <?xml version="1.0" encoding="UTF-8"?> header at the top of the results but not from the "live" version
-
Re: Rendering Content as XML for AJAX

6 January 2010 at 4:24am
Any ideas? Enabling API access will give me an XML of the table, but I need access to resized image URLs
| 1300 Views | ||
|
Page:
1
|
Go to Top |

