php - AJAX AND JSON within Codeigniter -


I have a website where I want to get some query results through AJAX and JSON, but I do not know at all How to do this, I have this function,

  public function range () {$ table = $ this-> Uri-> Segment (2); $ Content_id = $ this- & gt; Yuri- & gt; Segment (3); $ Data ['content'] = $ this- & gt; Site_model- & gt; Get_content ($ table, $ content_id); $ This- & gt; Load-> View ('template / right-content', $ data); }  

The query that is being run is dynamic, how the URL is passing, what I want, the user clicks on some link

  & lt; A href = "/ category / blog / 1" id = "blog" & gt; Read the blog & lt; / A & gt;  

With this link, I get the blog and pass it through 1 question, but I have to load the loaded results in my main template and then click on a link every time. The same thing without writing on the previous data is done, does anyone have any idea how to do this?

If I understand you correctly, you need to send an AJAX request to that URL and After that, the appropriate place in your document is to add something like this:

  $ ("# blog"). Click (function () {var url = $ (this) .attr ("href"); $ .ajax ({url: url, type: "post", success: function (html) {$ ("# someDiv "). Attachment (html);}}};});  

So that the content in the Codeigniter view should only really be included, in fact, and perhaps it requires some markup to style. The container where the content is given should already be in the page where the link is starting.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

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