Welcome Guest, Not a member yet? Register   Sign In
I can't get the responce for ajax post call.
#8

[eluser]chefnelone[/eluser]
I started again from a clean codeigniter application and I got it working but with this problem:
In the js function I must to use this line:
$.post('index.php/test/processFormAjax' , $(this).serialize() , function(html){...

But... it doesn't work if I change that line to this:
$.post( base_url + 'test/processFormAjax' , $(this).serialize() , function(html){...
or
$.post('/test/processFormAjax' , $(this).serialize() , function(html){...
or
$.post('/processFormAjax' , $(this).serialize() , function(html){...



I create this very simple example:

The example uses this code:

'test.php' Controller:

Code:
class Test extends Controller {

    function Test()
    {
        parent::Controller();    
    }
    
    function index()
    {
        $this->load->view('test');
    }
    
    function processFormAjax(){
    
        echo "Data sent from the method";    
    
    }
}

test.php View
Code:
<html>
<head>

script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"> script

script


base_url = '<?php echo base_url(); ?>';

$(document).ready(function() {

   $('#test').submit(function(eve) {
   eve.preventDefault();

        $.post('index.php/test/processFormAjax' , $(this).serialize() , function(html){
        //$.post( base_url + 'test/processFormAjax' , $(this).serialize() , function(html){

        alert(html);

        });

    });
});


script

</head>
<body>

<?php
$attributes = array('id' => 'test');
echo form_open('test/processForm', $attributes);
?>
    
    <input type="text" name="field1"  value="any value"/>
    <input type="submit" value="Submit" />

</form>


</body>
</html>


Messages In This Thread
I can't get the responce for ajax post call. - by El Forum - 02-11-2010, 09:25 AM
I can't get the responce for ajax post call. - by El Forum - 02-11-2010, 09:28 AM
I can't get the responce for ajax post call. - by El Forum - 02-11-2010, 09:48 AM
I can't get the responce for ajax post call. - by El Forum - 02-11-2010, 02:16 PM
I can't get the responce for ajax post call. - by El Forum - 02-11-2010, 02:36 PM
I can't get the responce for ajax post call. - by El Forum - 02-11-2010, 03:15 PM
I can't get the responce for ajax post call. - by El Forum - 02-11-2010, 06:32 PM
I can't get the responce for ajax post call. - by El Forum - 02-12-2010, 02:22 AM
I can't get the responce for ajax post call. - by El Forum - 11-27-2010, 03:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB