php - Codeigniter URI and jquery/javascript -


I have a method in the codeigniter that looks like this,

  public function range () {// $ this-> Output-> Enabled_proffeiler (TRUE); // echo "Halo function called by ajax"; $ Table = $ this- & gt; Uri-> Segment (3); $ Content_id = $ this- & gt; Yuri- & gt; Segment (4); $ Data ['content'] = $ this- & gt; Site_model- & gt; Get_content ($ table, $ content_id); $ This- & gt; Load-> View ("call", $ data); }  

This method is called through AJAX and the results are returned without the user leaving the page, this means that the URI is never passed, hence the CI Can not get the segment but I have the URL out with jquery out there i can add my url variables which is built in javascript and somehow those values ​​i need in php? Click

My Javascript

  $ ("A.navlink") (function (ev) {$ (this) .toggleClass ("active"); ev.preventDefault (); Var id = $ (this) .attr ("id") if ($ (this). HasClass ("active")) {$ ("." + Id) .remove ();} Other {// $ (This) .toggleClass ("active"); var url = $ (this) .attr ("href"); $ .ajax ({url: "index.php / home / category", type: "GET" Success: function (html) {// warning ("success"); $ ("#ordion"). Append ($ ("
"). Append (html ));}});}}};

You must add the ID to your Javascript at the end of the URL.

Like: ...

  $ Ajax ({url: "index.php / home / category /" + id, type: "GET",  

...

I think you You can also convert your PHP to:

  & lt; php function range ($ content_id) {/ $ $ Content_id = $ this- & gt; uri- & gt; Segment (4) ; $ Data ['content'] = $ this- & gt; site_model- & gt; get_content ($ table, $ content_id); $ the- & gt; load - & gt; view ("call", $ data); }? & Gt;  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -