Welcome Guest, Not a member yet? Register   Sign In
AJAX help wanted

(07-18-2017, 10:41 AM)Wouter60 Wrote: First, load jQuery in the head section of your view.
Then, before the </body> closing tag, have this piece of code:

    var url = "<?= site_url();?>controller/method";
    $.get( url, { p1: val1, p2 : val2 })
    .done(function(data) {
            //handle the returned data here

In the controller, use $this->input->get('p1') to read the value of p1.
Let the controller method echo the data that you need back in the view.

Many thanks for the suggestion. 

The following day I tried the AJAX call again and it worked for some weird reason! The previous day I had checked the filename and path, also tried renaming the file and using a different path, checked log files, file permissions, htaccess file, etc, etc, etc  and all to no avail.

Don't you love programming Smile

Messages In This Thread
AJAX help wanted - by John_Betong - 07-18-2017, 09:52 AM
RE: AJAX help wanted - by Wouter60 - 07-18-2017, 10:41 AM
RE: AJAX help wanted - by John_Betong - 07-21-2017, 01:22 AM
RE: AJAX help wanted - by InsiteFX - 07-22-2017, 02:29 AM
RE: AJAX help wanted - by PaulD - 07-22-2017, 02:16 PM

Theme © iAndrew 2016 - Forum software by © MyBB