Welcome Guest, Not a member yet? Register   Sign In
how to access the data i posted through ajax on my controller
#6

(This post was last modified: 08-16-2017, 06:42 PM by ciadvantage.)

Would you check your form if the email input with 'attribute' name='email' and  password input name='password'?

Code:
<form>
  <p>Email:<input type='text' name='email' />
</p>
<p><input type='password' name='password' /></p>
<input type='submit' value='Submit' />
</form>
<script>
   var data=$('form').serialize();
   var url = 'your_url'; // ie. login/identifying_usertype
    $('form').on('submit',function(e){
              e.preventDefault();
  
   $.post(url,data,function(response){
     
     },'json').done(function(response){
         console.log(JSON.stringify(response));// should have response data here
     }).fail(function(){
         //some action as you please
     });//end post
     });//end submit
</script>
 
  then in the controller:
  
Code:
public function identifying_usertype()

 $data=$this->input->post(NULL,TRUE);

 echo json_encode($data); //should response as json string at view
}

 Try that code and see if  you see the response.  I m pretty sure you should!
 Good luck
Reply


Messages In This Thread
RE: how to access the data i posted through ajax on my controller - by ciadvantage - 08-16-2017, 06:40 PM



Theme © iAndrew 2016 - Forum software by © MyBB