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


I can't get the responce for ajax post call.(using jquery).
But this problem just happens in the remote server. In my locallhost works fine. :ohh:

I have the form:
<form id='test'>
<input type="text" name="xxx" value="test" />
<input type="submit" value="enviar"/>

the js:
$(document).ready(function() {
  $('#test').submit(function(eve) {
     $.post('/shop/test' , $(this).serialize() , function(html){
     //I can't get 'html' which should contain "Data from the method" text


and the method in shop controller:
function test()
            $data = "Data from the method";
                echo $data;
                $this->firephp->log( $data);
                // I get this, so the method is called from the javascript

I cant's spot the mistake. ..

Use firebug to capture any xmlhttprequests


You mean the Console?

As far as I understand the path to the method is correct. (but it is in red, I don't know why)

I even get the message from the method (using $this->firephp->log( $data ); )

How can it work fine in my locallhost but not in the remote server?

I'm blank. What can I do?

This is what I get in the Console(images for 'Sent' and 'Headers')

[eluser]Eric Barnes[/eluser]
Now I don't know much about jquery but should it not be "success: function()" instead of just function?

Have you tried calling the URI and making sure its not erroring?

[quote author="SpooF" date="1265942194"]Have you tried calling the URI and making sure its not erroring?[/quote]

Hello spoof. can you tell me how to do it please.

[eluser]Jake Grice[/eluser]
I had this problem the other day on a simple email form that used Ajax with almost the exact same setup. (Serializing a form with $.post).

It just wouldn't alert the return value.

After debugging it, and getting it to work, it turned out to be an error in the native mail function so I used SMTP.

Try making your test function echo out text without doing anything else.

What is the URL of the project?

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){...
$.post('/test/processFormAjax' , $(this).serialize() , function(html){...
$.post('/processFormAjax' , $(this).serialize() , function(html){...

I create this very simple example:

The example uses this code:

'test.php' Controller:

class Test extends Controller {

    function Test()
    function index()
    function processFormAjax(){
        echo "Data sent from the method";    

test.php View

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


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

$(document).ready(function() {

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

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






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



change the name of the function from 'test' to anything..

I don't know why but codeigniter ignores functions with the name 'test'...

Theme © iAndrew 2016 - Forum software by © MyBB