Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating an API in yii for cross domain communication
    primarykey
    data
    text
    <p>I am planning to create a Restful API in yii for cross domain communication. As what I have researched, cross domain communication can only be done via jsonp and my implementation is as follows:</p> <p>UsersController:: actionCrossDomain</p> <pre> public function actionCrossDomain(){ $this->layout=false; $data['data']['User']['name']= 'Johny'; $this->_sendResponse(200, CJSON::encode($data),'application/json'); } </pre> <p>UsersController::_sendResponse methdod it is the same as you can see in :<a href="http://www.yiiframework.com/wiki/175/how-to-create-a-rest-api/#hh12" rel="nofollow">Click here </a></p> <p>On another server that i configured using virtual host, I am invoking the above method via ajax:</p> <pre> $( document ).ready(function() { $.ajax({ type: "POST", dataType: "jsonp", url:'http:'http//uxaserver.local/alpha2/app/users/crossDomain' , data: null, processData: false, crossDomain: true, contentType: "application/json", success: function (data) { console.log("done"); }, error: function (request, status, error) { console.log(request); } }); }); </pre> <p>The issue is my firebug is is complaining that : <pre>SyntaxError: invalid label</pre></p> <p>My requirement is such because I am helping my client's to do some customized analytic to his other websites and I need to put a script in his web pages of different domains so that the analytic data is recorded in the main server. I understand that I need to use the rest interface to communicate thus I am taking this approach. I am not sure if I have taken the right approach and please advice. I want to make it in a way where a client has an api key and can communicate with the api provided by me.</p> <p>Is there any other approach to do this? Rather than jsonp?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload