Posts tagged ‘fix’

jQuery AJAX & Internet Explorer

Internet Explorer getJSON trouble

This piece of code initially did not work for me on IE:

$.getJSON(“../inc/exercise_ajax.php?” + $(this).serialize(), function(json)

FireFox worked without problems.

The reason is that my JSON code was not well-formed. It had a comma (‘,’) too much.

Here’s the code which I use in PHP to create my JSON (braces omitted):

foreach($answers as $question => $answer){
$outstr .= ‘”q’.$question.’”: ‘;
if (isset($_GET[$question])){
if ($_GET[$question] == $answer) $outstr .= ‘true’;
else $outstr .= ‘false’;
} else $outstr .= ‘null’;
$outstr .= ‘,’;
}
echo chop($outstr,’,');

You have to chop off the trailing comma – if you don’t, IE will choke on it and your callback function won’t be executed.

Internet Explorer & AJAX caching

Yes, Internet Explorer caches your requests. You’ve got to empty the browser cache before testing the fix I mentioned. Also, you should append a unique parameter to suppress caching, i.e. the current timestamp. Example:

var now = new Date();
// submit with AJAX
$.getJSON(“../inc/exercise_ajax.php?ts=” + now.getTime() + ‘&’ + $(this).serialize(), function(json)

Concrete5 errors

Fatal error: Class ‘CollectionAttributeKey’ not found in (…)/concrete/models/collection.php on line 183

This class is defined in concrete5.3.3.1\concrete\models\attribute\categories\collection.php

The problem is easily resolved by loading the appropriate model in your code:

Loader::model(‘attribute/categories/collection’);

Russian and Chinese editing with Concrete 5

concrete multi language

It is not enough to add a Character set to your Template // or store it in UTF-8 without BOM (so the headers attached by PHP won’t break).

If TinyMCE only displays gibberish instead of the Russian / Chinese / … text you entered in edit mode, you should edit your .htaccess (located in the root directory of your site) and add the following:

AddDefaultCharset UTF-8

Optionally, while you’re at it, you can enable caching for your site:

#Speed UP!
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault “access plus 10 years”
ExpiresByType text/html “access plus 30 seconds”
</IfModule>

MySQL

[25-Feb-2010 16:15:46] PHP Warning: mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2) in … on line 38
[25-Feb-2010 16:15:46] PHP Warning: mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: A link to the server could not be established in … on line 38
(…)

Lösung des Problems:
die Funktion mysql-real-escape-string erfordert eigentlich zwei Parameter: zuerst den $unescaped_string, dann die resource $link_identifier. Lässt man zweiteres weg, versucht MySQL die aktuell zuletzt geöffnete Verbindung zu benutzen.

Ich habe in meinem Skript den Zugang zur Datenbank erst danach geöffnet. (Das ist der wichtigste Unterschied zwischen mysql_escape_string und mysql_real_escape_string – ersteres erfordert KEINEN Zugriff auf die Datenbank!)

Lectora and unterminated string literals

Sometimes Lectora renders the HTML, and you end up with broken pages. You start trying to disable things, sometimes it works, sometimes it doesn’t.

My advice: first use Firefox’ error console to find out what the error is about. Sometimes it’s an “unterminated string literal“:

VarAktuellerKapitelname.set( ‘El modelo biopsicosocial integrativo de la CIF

‘ )

You can solve this problem by patching the file and re-copying it over the output when rendering. (Of course you have to keep track of whether the page gets updated …)

Here’s the correct version of this line of code:

VarAktuellerKapitelname.set( ‘El modelo biopsicosocial integrativo de la CIF’ )

Easy, huh? The real challenge lies in tracking the little files … Well, why don’t you make it our problem? We’ll solve Lectora problems for you – ask for our competitive rates!

JQuery Tools and Tabs in IE

Internet Explorer’s refusing to work with the tabs – that is, the first two tabs work then everything breaks. Firefoxy and Opera do what I intend them to do. Have I mentioned that cross-browser developing can be a burden?

It turns out, that Internet Explorer has a problem with the <FORM> not wrapping around everything, but being split up between DIVs.

This does not work with Internet Explorer:

<div class=”panes”>
<DIV>
<form action=”/” method=”post”>

</DIV>
<DIV>

</DIV>
<DIV>
</form>
</DIV>
</DIV><!–closing the panes–>

This works:

<form action=”/” method=”post”>
<div class=”panes”>
<DIV>

</DIV>
<DIV>

</DIV>
<DIV>
</DIV>
</DIV><!–closing the panes–>
</form><!–form wraps around the panes –>