21297 Posts in 5734 Topics by 2603 members
General Questions
SilverStripe Forums » General Questions » Ajax – special characters (æ, ø & Ã¥) makes jQuery.load break
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 2089 Views |
-
Ajax – special characters (æ, ø & å) makes jQuery.load break

28 August 2009 at 8:24am Last edited: 28 August 2009 8:27am
Hi
I have a normal ajax-function that works fine. It executes with this jquery-code in the template:
<a href="#" onclick="jQuery('#ajaxContent').load('http://localhost:8888/mysite/kontakt/erstatBillede/299'); return false;">
And the php-code also works fine:
function erstatBillede()
{
if($this->isAjax)
{
$BilledeID = Director::urlParam("ID");
$Billede = DataObject::get_one("BilledeObject", "BilledeID = $BilledeID");
return $Billede->renderWith("ajaxSnippet");
}
else
{
return Array();
}
}And at last the code for the ajaxSnippet:
<% control Billede %>
<a href="$URL" class="group" title='$Title' rel="galleri">
<img class="thumb" src="<% control SetWidth(360) %>$URL<% end_control %>" alt='$Title'/>
</a>
<% end_control %>$HTMLBeskrivelse
Now the problem is the HTMLTextfield: $HTMLBeskrivelse - this is plain html-code made in a SimpleTinyMCEField in an object powered by the DataObjectManager module. All of this also works fine, except when I use special characters like æ, ø and å in danish.
I've checked my database and it uses UTF-8 just like the html-template, so I guess that shouldn't be the problem.
If I change $HTMLBeskrivelse from "HTMLTextfield" to "Textfield" then I get raw html code out into the template. For some reason it just doesn't work as html-text.
I've also done a ContentNegotiator::disable(); in _config.php, but this doesn't make any difference.
Can anyone help?
-
Re: Ajax – special characters (æ, ø & å) makes jQuery.load break

28 August 2009 at 9:12am
Found a solution on this problem. I've been using ZendAMF to retrieve some data from Silverstripe to ActionsScript 3 and I remember having a similar problem. So I used this PHP function called html_entity_decode, which apparantly also helped with my AJAX problem:
function erstatBillede()
{
if($this->isAjax)
{
$BilledeID = Director::urlParam("ID");
$Billede = DataObject::get_one("BilledeObject", "BilledeID = $BilledeID");
$Billede->HTMLBeskrivelse = html_entity_decode($Billede->HTMLBeskrivelse, ENT_NOQUOTES, "UTF-8");
return $Billede->renderWith("ajaxSnippet");
}
else
{
return Array();
}
}If you have any insight on this issue please post and share.
-
Re: Ajax – special characters (æ, ø & å) makes jQuery.load break

28 August 2009 at 9:58am
Unfortunately this is the sad reality that is UTF-8 compliance. Decoding/Encoding the entities with php's built in functions as you are doing might be the best option. You might also give shot with iconv for comprehensive language set conversion:
-
Re: Ajax – special characters (æ, ø & å) makes jQuery.load break

28 August 2009 at 7:29pm
Ok, thanks for the reply...
| 2089 Views | ||
|
Page:
1
|
Go to Top |


