jquery的ajax
在CI中使用jquery的$.ajax传递数据到控制器中$.ajax({
type: 'post',
dataType: 'script',//'json',
cache: false,
url: <?php echo '"' . site_url('ajax_post/post_action') . '"'; ?>,
data: 'username=' + username + '&password=' + password,
success: function(data){
// alert(data.message);
// $("#form_message").css({"background-color": data.bg_color}).fadeIn('slow');
},
error: function(data) {
// alert('error');
// $("#form_message").html("An error occurred!");
}
});
在控制器ajax_post的post_action方法中输出
$message = '123456';
echo "alert(" . $message . ")";
当$message字符串内容为数字时,可以弹出警告框,但当$message变量中含有字母是,IE会在左下角提示错误,郁闷呢,不知道为啥,请高手帮忙!
本帖最后由 jeongee 于 2011-9-15 13:20 编辑
echo "alert('" . $message . "')"; 确实是这个问题,版主,谢了
页:
[1]