Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

codeigniter 3 return json response

//do the edit in your javascript

$('.signinform').submit(function() { 
   $(this).ajaxSubmit({ 
       type : "POST",
       //set the data type
       dataType:'json',
       url: 'index.php/user/signin', // target element(s) to be updated with server response 
       cache : false,
       //check this in Firefox browser
       success : function(response){ console.log(response); alert(response)},
       error: onFailRegistered
   });        
   return false; 
}); 


//controller function

public function signin() {
    $arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);    

   //add the header here
    header('Content-Type: application/json');
    echo json_encode( $arr );
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to start json server 
Javascript :: first x characters of string javascript 
Javascript :: loopback get relationship in before save 
Javascript :: how to concurrently run angular and node 
Javascript :: javscript generate empty 2d array 
Javascript :: jquery scroll when object appear on screen make animation 
Javascript :: shadow border react native 
Javascript :: stack implementation in javascript using array 
Javascript :: regex min length max length 
Javascript :: how to reset auto numeric js for input 
Javascript :: jsx if block 
Javascript :: Get full year from date object 
Javascript :: console log returns object object 
Javascript :: fb login npm 
Javascript :: jquery validation plugin 
Javascript :: js bmi calculator 
Javascript :: js union arrays 
Javascript :: javascript escape html string 
Javascript :: how to format multiline string in javascript 
Javascript :: sort array of objects javascript by value 
Javascript :: redirect browser javascript 
Javascript :: event handling in react documentation 
Javascript :: array sort by key javascript 
Javascript :: js is number 
Javascript :: how to find factorial of a number using Recursion in javascript 
Javascript :: react native transform 
Javascript :: get input value in react using hooks 
Javascript :: js get all query string 
Javascript :: pass data navigate react router dom 
Javascript :: check element exist in jquery 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =