I am having a problem trying to get ajax functioning properly, everytime I do a call i get
An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /system/ajax
StatusText: Internal Server Error
ResponseText:
What am i trying to do is have the drop down fill with the results of a function from api. The function works perfectly it gets the results when needed however the problem is with the ajax I even try to print out hello world and still got the 500 error.
this is the code I currently have, any advice is appreciated.
function autotitleform($form, &$form_state){
$form['vehicle_info'] = array(
'#type' => ('fieldset'),
'#title' => t('Vehicle Information'),
);
$form['autoinfo']['vehicle_year'] = array(
'#type' => 'select',
'#title' => t('Vehicle Year'),
'#options' => auto_title_year_api(),
'#ajax' => array(
'callback' => 'auto_title_make_api_callback',
'wrapper' => 'api_make'
),
);
$form['autoinfo']['wrapper'] = array(
'#prefix' => '<div id="api_make">',
'#suffix' => '</div>',
);
$options = array('- Select Make -');
if(isset($form_state['values']['vehicle_year'])){
$options = auto_title_make_api();
}
$form['autoinfo']['wrapper']['make_description'] = array(
'#title' => t('City'),
'#type' => 'select',
'#options' => auto_title_make_api(),
);
if(isset($form_state['values'])){
$form['page_output'] = array(
'#markup' => autotitledb_submit($form, $form_state)
);
}
return $form;
}
function auto_title_make_api_callback($form, $form_state) {
return $form['autoinfo']['wrapper'];
}
function auto_title_make_api(){
$url_make = 'https://test.api.800loanmart.com/Loanmartservice.svc/soapssl'; // SOAP 1.1
$post_str_make = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetVehicleMakes xmlns="http://tempuri.org/">
<customerId>73c858f0-791c-454e-b4d5-5634bf13621d</customerId>
<authenticationId>3074940f-7efe-447c-a7ff-3c152acdf8c4</authenticationId>
<year>2000</year>
</GetVehicleMakes>
</s:Body>
</s:Envelope>';
$headers_make = array(
'Content-type: text/xml; charset="utf-8"', // For SOAP 1.1 - JHW Jan 26, 2013
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: \"http://tempuri.org/ILoanmartService/GetVehicleMakes\"",
"Content-length: ".strlen($post_str_make) // Amount of data in bytes to be posted
);
$options_make = array(
CURLOPT_RETURNTRANSFER => true, // return web page / XML result
CURLOPT_HEADER => 0, // 1/0 return/don't return headers 0 for production or 1 for debug
CURLOPT_HTTPHEADER => $headers_make, // post headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
// Browser/User Agent String
CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
CURLOPT_TIMEOUT => 120, // timeout on response
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
CURLOPT_POST => 1, // We are sending post data needs to be = '1'
CURLOPT_POSTFIELDS => $post_str_make, // this is the XML post data
CURLOPT_PORT => 443, // SSL Port, probably unnesecery
CURLOPT_SSL_VERIFYHOST => false, // Don't verify ssl on either side
CURLOPT_SSL_VERIFYPEER => false, // dito, don't verify ssl on either side
CURLOPT_VERBOSE => 1, // Set to 1 for debug
);
$soap_do_make = curl_init($url_make);
curl_setopt_array($soap_do_make, $options_make);
$result_make = curl_exec($soap_do_make);
$sls_make = simplexml_load_string($result_make);
$sls_make->registerXPathNamespace('a', 'http://schemas.datacontract.org/2004/07/LM.API');
$sls_list_make = $sls_make->xpath('//a:MakeDescription');
foreach($sls_list_make as $sls_list_make_child){
$sls_list_make_child_result[] = sprintf("%s", $sls_list_make_child);}
dpr($sls_list_make_child_result);
$sls_list_make_child_results = array_combine($sls_list_make_child_result, $sls_list_make_child_result);
// Close cURL
curl_close($soap_do_make);
return $sls_list_make_child_results;
}
function auto_title_year_api(){
$url_year = 'https://test.api.800loanmart.com/Loanmartservice.svc/soapssl'; // SOAP 1.1
$post_str_year = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetVehicleYears xmlns="http://tempuri.org/">
<customerId>73c858f0-791c-454e-b4d5-5634bf13621d</customerId>
<authenticationId>3074940f-7efe-447c-a7ff-3c152acdf8c4</authenticationId>
</GetVehicleYears>
</s:Body>
</s:Envelope>';
$headers_year = array(
'Content-type: text/xml; charset="utf-8"', // For SOAP 1.1 - JHW Jan 26, 2013
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: \"http://tempuri.org/ILoanmartService/GetVehicleYears\"",
"Content-length: ".strlen($post_str_year) // Amount of data in bytes to be posted
);
$options_year = array(
CURLOPT_RETURNTRANSFER => true, // return web page / XML result
CURLOPT_HEADER => 0, // 1/0 return/don't return headers 0 for production or 1 for debug
CURLOPT_HTTPHEADER => $headers_year, // post headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
// Browser/User Agent String
CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
CURLOPT_TIMEOUT => 120, // timeout on response
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
CURLOPT_POST => 1, // We are sending post data needs to be = '1'
CURLOPT_POSTFIELDS => $post_str_year, // this is the XML post data
CURLOPT_PORT => 443, // SSL Port, probably unnesecery
CURLOPT_SSL_VERIFYHOST => false, // Don't verify ssl on either side
CURLOPT_SSL_VERIFYPEER => false, // dito, don't verify ssl on either side
CURLOPT_VERBOSE => 1, // Set to 1 for debug
);
$soap_do_year = curl_init($url_year);
curl_setopt_array($soap_do_year, $options_year);
$result_year = curl_exec($soap_do_year);
$sls_year = simplexml_load_string($result_year);
$sls_year->registerXPathNamespace('a', 'http://schemas.datacontract.org/2004/07/LM.API');
$sls_list_year = $sls_year->xpath('//a:Year');
foreach($sls_list_year as $sls_list_year_child)
{$sls_list_year_child_result[] = sprintf("%s", $sls_list_year_child);}
$sls_list_year_child_results = array_combine($sls_list_year_child_result, $sls_list_year_child_result);
// Close cURL
curl_close($soap_do_year);
return $sls_list_year_child_results;
}
Edit #1
The errors I am gettings are
Notice: Undefined index: #options in form_select_options() (line 2661 of /home/loansdotorg/public_html/includes/form.inc).
And
Warning: Invalid argument supplied for foreach() in form_select_options() (line 2668 of /home/loansdotorg/public_html/includes/form.inc).
Edit #2 I think I have this working although I will need to test it out more.