Lewis
Lewis

Reputation: 14876

Yii - Yii::app()->request->isAjaxRequest?

I'm a little bit confused about isAjaxRequest. Why and When should I use this? Is this important when data sent by a jQuery AJAX submit form?

Upvotes: 4

Views: 4909

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038880

You could use this method in order to test whether the controller was invoked with an AJAX request or not. This might allow you to do some adaptive rendering. For example if it wasn't an AJAX request return HTML, if it is an AJAX request return JSON.

Upvotes: 4

Related Questions