I’m trying to find out if it’s possible to have ajax links together with normal Post request.
Another thing worth mentioning is the case when people disallow ActiveX in IE. By default jQuery will respond but ajax will not work because Microsoft.XMLHTTP isn’t allowed to load. (Flash content is also affected by disallowing ActiveX, but that’s a different story.)
From jquery.js (1.3.2)
Since IE6 seems to be more or less history it might be worth to give XMLHttpRequest a try in IE7/IE8. Seems to work for me, so far.
I would think it would be something like this. And I only know this because I spent a bunch of time a couple weeks ago trying to figure it out. Except that I just found a new option for it
'Update Post', // The text for the anchor tag
'/site/updatePost', // The url for the ajax request
array( // The ajaxOptions (jQuery stuff)
'dataType' => 'json', // Page will output json to parse
'data' => array('ajax' => 1, ...), // The $_GET data (parameters) to pass
array( // The htmlOptions for the anchor tag
'href' => '/site/updatePost' // This is what the href of the anchor will be, defaults to #
// ^^ that's the new option I found out about, I didn't know it worked that way...
By passing ‘ajax’ in, you can then just put a switch at the bottom of your action that is something like this:
// If ajax request, output the json result
if (isset($_REQUEST['ajax']) && $_REQUEST['ajax'])
Yii::app()->end(); // Not necessarily required, but it can't hurt
// Otherwise, render the normal HTML template
'result' => $result,
I think that should basically do the same thing that I wrote above but in an automated way…
This is correct. It allows the search engines to also spider and index the pages that would otherwise only be accessible via ajax. The usefulness of that, however, only depends on whether or not the pages need to be indexed and if their content is relevant.