I'm having a bit of an issue with a jQuery call. I have this bit of code:
<script type="text/javascript">
jQuery('input[name="location"]').click(function(){
var data = {clocation : jQuery(this).val(), department : $('input[name="department"]:checked').val()};
jQuery.ajax({
url: "/new.php",
type:'POST',
data: data,
dataType: 'html',
success: function(result){
jQuery('#div-custom').html(result).show();
}
});
});
</script>
Here is new.php:
echo 'Here is your data:';
print_r($custom_data[0]); //This contains a mix of HTML and JavaScript
echo 'End of Data';
The new.php file generates a mix of HTML and JavaScript to return. If I manually access new.php and pass in the data, the content renders with no issue. However, when it is being passed back through the jQuery the JavaScript portion is failing. I know it must be related somehow to the dataType but I'm not sure how to overcome this.
Thank you for any help!