Js+Ajax Calling Action From Outside The Application

after finishing the web application I want to make a phoneGap app

that send/recieve JSON to my controllers

for start

  1. in the same controller I add other action

public function actionCreateCar_Mobile() {

    $model = new Car;



        $model->CarId= 1;

        $model->CarColor= 'RED';

        return  CJSON::encode($model);


write JS to send ajax request to get that model

$(document).ready(function () {

$('#btn').bind('click',function(){ getCar()});

        function createNewUser() {


            type: "GET",

            url: "http://localhost/VS/index.php/Car/CreateCar_Mobile",

            cache: false,

            data: '' ,

            success: onSuccess,

            error: onError


        return false;}

	function onSuccess(data, status){ alert(data); }

function onError(data, status)

{ alert("Error Submitting Form");  }


is this a right wat to do what I’m trying to do ?

when I click the btn it give me an empty alert ! why did not show the json from the action

what is the best way to handle authentication