Welcome Guest, Not a member yet? Register   Sign In
Does anyone see why my jquery ajax call is not posting?
#1

[eluser]Bart v B[/eluser]
Hello all,

I have a problem with my ajax call.
He does not post to my controller where I should get an output.
someone might see what I overlooked?
a simple print_r ($ _POST) gives an empty array.
When I request him to the controller I get the proper value back.

My jquery code:
Code:
$(document).ready(function() {
    $('select').change(function() {
          //alert('Changed!');
        var item = $('#item').val();
        //alert(item); works
        
        $.ajax({
           type: "POST",
           url: "http://localhost/cobra-scripters.nl/hostingplan/",
           data:$(this).val(), //works also
           success: function(data) {
           $("#display").html(data);          
           }
          
         });

    });
    
});

My form code:
Code:
<fieldset>
          
            <legend>Maak een keuze</legend>
            <div id="display"></div>
            
            &lt;?php echo form_open('webhosting/bestel');?&gt;
            <label class="forminput" for="item">Keuze</label>
            <select name="item" id="item">
              <option value="" >--</option>
              <option value="1">shared hosting</option>
              <option value="2">wegwerp hosting</option>
              <option value="3">sleur pleur hosting</option>
            </select><br />
             &lt;input type="submit" value="Volgende" class="knop" /&gt;&lt;br />
            &lt;?php echo form_close(); ?&gt;
            
        </fieldset>

my controller
Code:
&lt;?php

class Hostingplan extends Controller
{
    public function index()
    {
        print_r($_POST);
        $this->load->model('hosting_model');
        
            if($this->input->post('item') == 1 )
            {
                $id = ' per jaar';
            }
            if($this->input->post('item') == 2 )
            {
                $id = ' per call/sms per maand';
            }
            if($this->input->post('item') == 3)
            {
                $id = ' voor het standaard pakket';
            }
        
            
             $hostings = $this->hosting_model->getHosting();
              foreach($hostings as $hosting):
              $data=  '<h2><i>Uw keuze:</i> '.$hosting->name.'</h2>';
              $data.= '<p>De kosten zijn: &euro; <b>'.$hosting->price.' </b>'.$id.' inclusief BTW.</p>';
              $data.= '<p><a href="'.base_url().'webhosting/bestel/">Nee, toch een andere keuze</a></p>';
              endforeach;
            
            echo $data;
        }
    
}

So in short i don't get anything back from jquery.
thx for the help.


Messages In This Thread
Does anyone see why my jquery ajax call is not posting? - by El Forum - 12-10-2010, 02:10 AM
Does anyone see why my jquery ajax call is not posting? - by El Forum - 12-10-2010, 02:45 AM
Does anyone see why my jquery ajax call is not posting? - by El Forum - 12-10-2010, 08:07 AM
Does anyone see why my jquery ajax call is not posting? - by El Forum - 12-10-2010, 12:56 PM
Does anyone see why my jquery ajax call is not posting? - by El Forum - 12-10-2010, 01:02 PM



Theme © iAndrew 2016 - Forum software by © MyBB