Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Answering you question, and since CI doesn't seem to have implemented yet a proper support to javascript libraries, you can use a function like this to ensure that the information you're dealing with comes from ajax :</p> <p><a href="http://snipplr.com/view/1060/check-for-ajax-request/" rel="nofollow noreferrer">http://snipplr.com/view/1060/check-for-ajax-request/</a></p> <p>Note that this only works with javascript libraries like jQuery or MoonTools</p> <p>After that, you just need to deal with the information as if it was a normal page, getting the data with $this->input->post('field') or $this->input->get('field') sanitized variables.</p> <p>in a example (using jquery), suppose you have a anchor tag that you want to delete a row in a list of items :</p> <pre><code>$(function() { $('a.delete').click(function(e) { // prevents the default behaviour of the anchor e.preventDefault(); // gets the id stored in the anchor as attribute var cid= $(this).attr('cid'); // instantiate and executes the ajax $.ajax({ type: 'POST', url: 'http://www.yoursite.com/ajax.php', data: "action=delete&amp;cid="+cid, async: true, success: function(data){ // alerts the response, or whatever you need alert(data); } }); }); </code></pre> <p>After that, you just need to build your code in CI as a normal page. Note that I used normal url's in the ajax request (url for the base, data for the parameters), and don't know if it works properly with "url_rewrited" urls, but they might work with no problems, if you just use "url:" ajax parameter to insert the full url. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload