Error 400 JQuery + Yii

I have an AJAX call in my view to an action in my controller. However, I always get an Error 400. Below is the code for my AJAX call:

        cache: false,
        url: '/dummy/index.php/module/controller/checkCross',
        dataType: 'json',
        type: 'POST',
        data : {"male":parents[0],"female":parents[1]},
        success: function(result){

Below is the code in the controller:

 public function actionCheckCross(){

     if(Yii::app()->request->isPostRequest) { // check if POST
        $flag = CrossingMatrix::model()->checkParentsIfCrossed($_POST['male'],$_POST['female']);

            return true;

            return false;

    } else { // direct URL request will be GET, so show error
        throw new CHttpException(400, Yii::t('app', 'Direct access is not allowed.'));


Any ideas?


You are expecting json data, but you send empty page to browser. You should encode result like that:

echo CJavascript::jsonEncode((bool)$flag);

In your code you returned value. Notice that your yii exception message is Direct access is not allowed but your error is Your request is invalid.

Need Your Help

Detecting the largest partition in Linux

linux partitioning disk-partitioning

I created a backup solution for my job to backup Windows XP/7 computers that come in to the office by booting into Lubuntu from a USB and running a Java program that backs up to a network share.

How to read a .properties file inside a .xsl file?

xslt properties

I have an XSL file which uses a a static website link as shown below:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.