Search code examples
javascriptjqueryajaxyiiyii-extensions

yii-user registration form as popup using ajax in yii


am using yii-user extension for registration. it works perfect .but my reqiurement is to render the registration form using ajax on pages with menu ,which contains this register as menuitem .i dont want is user to be redirected to some other page. my need is on whichever page she may be she can register from their via ajax registration form on that particular page

  array('url'=>Yii::app()->getModule('user')->registrationUrl, 'label'=>Yii::app()->getModule('user')->t("Register"), 'visible'=>Yii::app()->user->isGuest),

this wrks and redirects me to user/registration page but my need is ajax popup up on any page when register item is clicked.

i did something like and in script

    function showmod()
{




 document.getElementById("showdata").style.display = "block";


 //alert("hi1");

 //  alert("hi");
    var xmlhttp;    

    if (window.XMLHttpRequest)
         {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
         }
      else
     {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
 xmlhttp.onreadystatechange=function()
  {
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
     {
    // alert("hi2");
    document.getElementById("showdata").innerHTML=xmlhttp.responseText;

//alert("h2");
  }
   }
   xmlhttp.open("GET","<?php echo Yii::app()->getModule('user')->registrationUrl ;?>",true);

    //alert("h1");


   xmlhttp.send();

    }

  array( 'url'=>'#','label'=>Yii::app()->getModule('user')->t("Register"), 'visible'=>Yii::app()->user->isGuest,array('click'=>"showmod()")),

doesnt work

a similar post i have posted https://stackoverflow.com/questions/22164620/yii-user-registration-view-in-model-window

as its been extracted in module folder .might be thats error i dont what is it please let me know

can anyone please help ,guide,suggest how do achieve so


Solution

  • here instead of

              xmlhttp .open("GET","<?php echo Yii::app()->getModule('user')->registrationUrl ;?>",true);
    

    this wrks

        xmlhttp.open("GET","<?php echo Yii::app()->request->baseUrl;?>/index.php/user/registration",true);