Difference between #9 and #10 of
Reliable Alternative For Yii::app()->request->isAjaxRequest AND Adding Data To Ajax Form With JS

Revision #10 has been created by ibo_s on Oct 9, 2011, 5:45:16 PM with the memo:

summary
« previous (#9)

Changes

Title unchanged

Reliable Alternative For Yii::app()->request->isAjaxRequest AND Adding Data To Ajax Form With JS

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

alternative, reliable alternative, isAjaxRequest, ajax form data, javascript, jquery, add form data

Content changed

In this How-To I'll show you: 1.) A reliable alternative to Yii::app()->request->isAjaxRequest (because it doesn't work for everybody and it's not reliable) 2.) How to add extra data to a formn ajax-request without setting a hiddenField in your form, only using javascript, before sending the form.

Here you can read more about why 'isAjaxRequest' isn't reliable:
[http://www.yiiframework.com/forum/index.php?/topic/4945-yiiapp-request-isajaxrequest/](http://www.yiiframework.com/forum/index.php?/topic/4945-yiiapp-request-isajaxrequest/ "yii app request isAjaxRequest")

The main idea is adding a parameter to our request which tells us if the current request is an ajax-request or not. So if you work with an ajax form, you would for example add a hiddenField named 'isAjaxRequest' and set the value to '1'.
[...]
12 1
10 followers
Viewed: 61 253 times
Version: 1.1
Category: How-tos
Written by: ibo_s
Last updated by: ibo_s
Created on: Oct 9, 2011
Last updated: 13 years ago
Update Article

Revisions

View all history