Thanks for the great tutorial. My REST client for Firefox is returning the data from the database, but I need to initialize my data before I load app.js.
<script type='text/javascript' src='<?php echo Yii::app()->request->baseUrl; ?>/scripts/js/jquery-1.7.1.min.js'><script>
<script type='text/javascript' src='<?php echo Yii::app()->request->baseUrl; ?>/scripts/js/underscore-min.js'></script>
<script type='text/javascript' src='<?php echo Yii::app()->request->baseUrl; ?>/scripts/js/backbone-min.js'></script>
<script>
var trucks = < I need to get the JSON string from ApiController via api/trucks >
</script>
<script type='text/javascript' src='<?php echo Yii::app()->request->baseUrl; ?>/scripts/js/app.js'></script>
Any help is appreciated.
New Yii REST Tutorial
#22
Posted 11 April 2012 - 02:58 PM
Sorry for responding to my own post, this works, but is there a better way?
<script>
var trucks = [];
$.ajax({
url: "/index.php/api/trucks",
dataType: "json",
method: "GET",
async: false,
success: function(response){
trucks = response;
}
});
</script>
<script type='text/javascript' src='<?php echo Yii::app()->request->baseUrl; ?>/scripts/js/app.js'></script>
<script>
var trucks = [];
$.ajax({
url: "/index.php/api/trucks",
dataType: "json",
method: "GET",
async: false,
success: function(response){
trucks = response;
}
});
</script>
<script type='text/javascript' src='<?php echo Yii::app()->request->baseUrl; ?>/scripts/js/app.js'></script>
#23
Posted 04 May 2012 - 07:21 PM
How to authentication
I use RESTClient addon Firefox but I dont know how to set header of it.
I try Content-Type: application/json and body HTTP_X_ASCCPE_PASSWORD=emo&HTTP_X_ASCCPE_USERNAME =aaaaaaaaaaaa
But it not return true
I use RESTClient addon Firefox but I dont know how to set header of it.
I try Content-Type: application/json and body HTTP_X_ASCCPE_PASSWORD=emo&HTTP_X_ASCCPE_USERNAME =aaaaaaaaaaaa
But it not return true
#24
Posted 07 May 2012 - 02:22 AM
sepdau, on 04 May 2012 - 07:21 PM, said:
How to authentication
I use RESTClient addon Firefox but I dont know how to set header of it.
I try Content-Type: application/json and body HTTP_X_ASCCPE_PASSWORD=emo&HTTP_X_ASCCPE_USERNAME =aaaaaaaaaaaa
But it not return true
I use RESTClient addon Firefox but I dont know how to set header of it.
I try Content-Type: application/json and body HTTP_X_ASCCPE_PASSWORD=emo&HTTP_X_ASCCPE_USERNAME =aaaaaaaaaaaa
But it not return true
In RESTClient, use the 'headers' functionality:
* menu 'Headers'
* 'Custom Header'
* 'Name' : X_ASCCPE_PASSWORD
* 'Value' : emo
And the same with USERNAME.
HTH,
JM.

Help












