Welcome Guest, Not a member yet? Register   Sign In
trying to call javascript
#7

(This post was last modified: 05-09-2019, 02:29 PM by InsiteFX.)

It already loads all the functions see the init function, then at the bottom you
can see that it loads itself.

The only way that I know how it to check the page post value then send an ajax call.

Code:
$(document).ready(function(){
   $("#button").on('click',function(){
           var name = $('#name').val();
           var email= $('#email').val();
           var data = 'name=' + name + '&email=' + email;
           $.ajax({
               url: 'login_processor.php',
               type: "POST",
               data: data,
               cache: false,
               dataType: "JSON",
               success: function(data){
                   if(data.error_name){
                       alert(data.error_name);
                       return false;
                   }
                   if(data.error_email){
                       alert(data.error_email);
                       return false;
                   }
               }
           });
       });
   });
//login_processor.php
   $error_name = null;
   $error_email = null;
   if(empty($_POST['name'])){
       $error_name = 'Please Enter Name!';
   }
   if(empty($_POST['email'])){
       $error_email = 'Please Enter Email!';
   }
   echo json_encode(array('error_name'=>$error_name, 'error_email' => $error_email));

Something like that you need to set it up for your stuff.

The url would point to your controller method.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
trying to call javascript - by richb201 - 05-07-2019, 03:05 PM
RE: trying to call javascript - by php_rocs - 05-07-2019, 07:03 PM
RE: trying to call javascript - by richb201 - 05-07-2019, 10:37 PM
RE: trying to call javascript - by richb201 - 05-08-2019, 05:34 AM
RE: trying to call javascript - by InsiteFX - 05-08-2019, 08:33 AM
RE: trying to call javascript - by richb201 - 05-09-2019, 09:32 AM
RE: trying to call javascript - by InsiteFX - 05-09-2019, 02:28 PM
RE: trying to call javascript - by richb201 - 05-09-2019, 04:11 PM
RE: trying to call javascript - by InsiteFX - 05-10-2019, 03:31 AM
RE: trying to call javascript - by richb201 - 05-10-2019, 06:04 AM
RE: trying to call javascript - by includebeer - 05-10-2019, 11:02 AM
RE: trying to call javascript - by richb201 - 05-10-2019, 03:56 PM
RE: trying to call javascript - by InsiteFX - 05-10-2019, 08:23 AM
RE: trying to call javascript - by Wouter60 - 05-10-2019, 10:46 AM
RE: trying to call javascript - by includebeer - 05-11-2019, 05:49 AM
RE: trying to call javascript - by InsiteFX - 05-11-2019, 08:18 AM
RE: trying to call javascript - by includebeer - 05-11-2019, 02:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB