php - Ajax Get Parent Page URI (Code Igniter) -


I'm loading content, primarily, dynamically using AJAX in a code igniter app. However, I need to get the URI segment to enter my DB and fill the date box on the form automatically. Normally one has to do something:

  $ date = $ this-> Uri-> Segment (3). "/". $ This- & gt; Uri-> Section (4) "/" $ this->. Uri-> Section (5);  

But obviously it tries to read the address of the document being called through the AJAX request, not the parent.

Thank you!

  & lt; Meta charset = "UTF-8" />  

& lt; Script type = "text / javascript" & gt; Tabs ({ajaxOptions: {error: function (xhr, status, index, anchor) {$ (anchor.hash) .html ("Unable to load this tab." We'll try to fix it as soon as possible. '}}}}}};}); & Lt; / script & gt; & lt; div id = "diary-input" & gt; & lt; div id = "tab" & gt; & lt; ul &

  • Php echo base_ url (). "Index.php / diary_add_event"? & Gt; Event & lt; / a & gt; & lt; / li & gt; & lt; li & gt; & lt; a href = "& lt ;? Php echo base_ url (). "Index.php / diary_add_client"? & Gt; "& gt; New Client & lt; / a & gt; & lt; / li & gt; & lt; li & gt; & lt; a href =" & lt ;? Php echo base_ url (). "Index.php / diary_add_contact"? & Gt; "& gt; New Contact "? & Gt; & lt; / a & gt; & lt; / div & gt; & lt; / ul & gt; & lt; / div & gt; & lt; / div & gt; < / Pre>

    with jQuery and jquery UI included in my document headers. If you need more info then I am using the jquery ui ajax tab:

  • When making a Ajax request, you should send it from the parent page to the segment.

    In your controller:

    < Pre-> $ data ['segment'] = $ this-> uri- & gt; segment (3). "/" $ This-> uri-> section (4) "/" $ This- & gt ;.uri- & gt; section (5);

    Your In Ichar:

      & lt; li & gt; & lt; a href = "& lt ;? Php echo base_ url (). "Index.php / diary_add_appt / {$ segments}"?  
  • Php echo base_ url (). "Index.php / diary_add_event / {$ segments}"? & Gt; Event & lt; / a & gt; & lt; / li & gt; & lt; li & gt; & lt; a href = "& lt ;? Php echo base_ url (). "Index.php / diary_add_client / {$ segments}"? & Gt; "& gt; New Client & lt; / a & gt; & lt; / li & gt; & lt; li & gt; & lt; a href =" & lt ;? Php echo base_ url (). "Index.php / diary_add_contact / {$ Segment}"? & Gt; "& gt; New Contact

  • Comments