[eluser]Katsune[/eluser]
Hey guys,
Here's my new code:
javascript file EDITED:
Code:
$(document).ready(function(){
//form validation for the empty search field
var searchInputVar = $('#searchInput').val();
$('form.ajaxForm').on('submit',function(){
if($("#searchInput").val().length<=0){
$("#SearchPrompt").css({"display":"inline","color":"red"});
return false;
}
else
{
$('form.ajaxForm').on('submit',function() {
$.ajax({
type: 'POST',
url: 'http://localhost/AnimeInventory/index.php/maincontroller/testForAjax',
data: searchInputVar,
success: function(smg) {
$("#info1").html('<li>Test'+smg+'</li>');
}
});
});
return false;
}
});
});
view
Code:
echo form_input('search','','id="searchInput"');
controller
Code:
public function testForAjax(){
$valueContainer = $data = array ('Holder'=>$this->input->post('search'));
print_r($valueContainer);
}
SAMPLE RESULT:
Code:
TestArray ( [Holder] => )
It's weird because what I see in the firebug is the source code of the website. But when I use console.log('test'); I can see the text "test" in firebug. Im expecting that the msg should produce the value that was echoed in the controller.
Please help. Thanks,