[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>
<?php echo form_open('webhosting/bestel');?>
<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 />
<input type="submit" value="Volgende" class="knop" /><br />
<?php echo form_close(); ?>
</fieldset>
my controller
Code:
<?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: € <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.