• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AJAX help wanted

#3
(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:

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

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
download and make your system directory strict
Reply


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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.