Please review the code fragments below:
First, the Javascript call:
function getNewSelect(property_id){
xajax_getSelectDropDown(unique_id);
$(".chzn-select").chosen();
}
Next, the PHP XAJAX function:
function getSelectDropDown($unique_id){
//CODE ABOVE THIS POINT HAS BEEN REMOVED, IT IS IRRELEVENT FOR THIS EXAMPLE
//Code for if no matches were found:
$html2 = NULL;
$objResponse = new xajaxResponse();
if(mysql_num_rows($result) > 0){
$objResponse->assign('subDiv', 'innerHTML', $html);
}else{
$objResponse->assign('subDiv', 'innerHTML', $html2);
}
$objResponse->script("$('.chzn-select-ajax').chosen();");
return $objResponse;
}
Finally here's the HTML code:
<div id="subDiv"></div>
Now, when the above PHP function goes into the else
and assigns $html2
- I expect nothing to be displayed to the user. On most browsers, that's fine and it works perfectly. Unfortunately on internet explorer (IE 9 I can confirm, I haven't been able to test other versions), it actually displays the following where the DIV call:
null
If a result is found and it does not process the else
, then it works correctly on all browsers and shows a new drop down as it's supposed to.
What can I do to fix this problem? Is this a known issue with IE? Thanks.
I want to add so there's no confusion, the CHZN call is just to add a style to the dropdown, as found here: http://harvesthq.github.com/chosen/
Better use this:
if(mysql_num_rows($result) > 0){
$objResponse->assign('subDiv', 'innerHTML', $html);
}else{
$objResponse->assign('subDiv', 'innerHTML', '');
}
IE is showing null because $html2 = NULL......better try it with $html2 = " " or something like that ;)
Saludos.