Yii Framework Forum: New Yii REST Tutorial - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

New Yii REST Tutorial Rate Topic: -----

#21 User is offline   mediawiz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 11-April 12

Posted 11 April 2012 - 02:15 PM

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.
0

#22 User is offline   mediawiz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 11-April 12

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>
0

#23 User is offline   sepdau 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 01-May 12

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
0

#24 User is online   Jean-Marie 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 12-April 12
  • Location:Brittany, France.

Posted 07 May 2012 - 02:22 AM

View Postsepdau, 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


In RESTClient, use the 'headers' functionality:
* menu 'Headers'
* 'Custom Header'
* 'Name' : X_ASCCPE_PASSWORD
* 'Value' : emo

And the same with USERNAME.

HTH,

JM.
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users