I'm trying to get a string from a php file, here:
$company = Company::find_by_id($_GET['company_id']);
$string = $company->output_information();
$output = array('key' => $string);
echo json_encode($output);
The main file has the following html:
<select id="step_one_check">
// some options
</select>
<div id="div_company_data">TBA</div>
<div id="step_two" style="display: none">Step two<div>
and the following jQuery:
$(document).ready(function(){
$("#step_one_check").change(function(){
$("#step_two").slideDown();
$.ajax({
url : '../includes/encode/company_information.php',
type : 'GET',
data : "company_id=" + $("#step_one_check").val(),
dataType : 'json',
success : function (result) {
alert("success");
$("#div_company_data").html(result.key);
},
error : function () {
alert("error");
}
});
});
The jQuery script makes step two slides down, but does not alert or #div_company_data. Any idea?
----- UPDATE -----
I've resolved the problem, it's my php file. After I included the Company class, the code worked.