Yii Framework Forum: Ajax Url In Js External File By Yii - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Ajax Url In Js External File By Yii Rate Topic: -----

#1 User is offline   Mengly007 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 21-January 13

Posted 07 February 2013 - 03:17 AM

Hi everyone!

I am new to start yii and now i got stuck in ajax

$.ajax({
type:"POST",
url:<<<<????>>>>,
data:{"uname":username,"pass":password},
success:function(msg){
//dosth
}
});


How can i put my php like <<<<data/action.php>>>> file in this style. As i've tried, it's not working

Could any guide me to do this. Thank in advance!
0

#2 User is offline   EdoFre 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 48
  • Joined: 24-February 11
  • Location:Groningen, The Netherlands

Posted 07 February 2013 - 04:17 AM

View PostMengly007, on 07 February 2013 - 03:17 AM, said:

Hi everyone!

I am new to start yii and now i got stuck in ajax

$.ajax({
type:"POST",
url:<<<<????>>>>,
data:{"uname":username,"pass":password},
success:function(msg){
//dosth
}
});


How can i put my php like <<<<data/action.php>>>> file in this style. As i've tried, it's not working

Could any guide me to do this. Thank in advance!


You do not need the .php following your action, that might be the problem, if you can use php use CController::createUrl('controller/action'), otherwise just try using '/controller/action'
Moi,
0

#3 User is offline   yugene 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 515
  • Joined: 08-August 09

Posted 08 February 2013 - 07:25 AM

The simple and usual Yii approach is to use CClientScript.registerScript()
Also you may write URL manually or pass it as js constant, but these are worse solutions IMO.
And write what exactly you entered as the URL in your script.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

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