if(count($listAddress)>0){
echo json_encode(array('res'=>'成功','status'=>1,'info'=>$listAddress));}else{
echo json_encode(array('res'=>'失','status'=>0));
}
<script type="text/javascript"> //属性操作 - removeClass() 方法
$(document).ready(function(){
$("button").click(function(){
$("p").removeClass("intro");
});
});
</script>
// Display a warning toast, with no title
toastr.warning(
'My name is Inigo Montoya. You killed my father, prepare to die!'
)
// Display a success toast, with a title
toastr.success(
'Have fun storming the castle!'
,
'Miracle Max Says'
)
// Display an error toast, with a title
toastr.error(
'I do not think that word means what you think it means.'
,
'Inconceivable!'
)
// Clears the current list of toasts
toastr.clear()
toast.success(11);
console.log('aaaaaaaaaa');
先执行此处:
<script>
$(document).ready(function(){
$('.prov{$k}').click(function(){
var prove = '{$vo['province']}';
$.post(U('Shop/Order/ajaxValue'),{name:prove},function(data){
//alert(data.info.14.goods_address);
if(data.status==1){
toast.success(11);
alert(data['info'][14]['goods_address'])
}else{
toast.error(222);
}
},"json"); //加这个转换成JSON 形式
});
});
</script>
再执行下面:
//商品的运费信息
public function ajaxValue($name='')
{
$fr=D('shop_freight');
//$list = $fr->order('f_id')->limit(1)->find();
$listAddress=$fr->order('f_id')->where('f_id>1 and goods_address like "%'.$name.'%"')->getField('f_id,goods_address,f_money,f_num,f_freight');
//echo D('shop_freight')->getLastSql();die;
if(!empty($listAddress)){
echo json_encode(array('res'=>'成功','status'=>1,'info'=>$listAddress));
}else{
echo json_encode(array('res'=>'失','status'=>0));
}
//echo D('shop_freight')->getLastSql();die;
//$this->assign('listAddress',$listAddress);
//$this->display("Index/goodsdetail");
}
下面图片的不存在:默认显示:
$(window).load(function() {
$('img').each(function() {
if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
this.src = 'http://www.tranism.com/weblog/images/broken.gif';
}
});
});
先检查图片是否加载成功,然后如果失败的话再绑定事件。而且替换一次就好了。
<img src="xxxx.jpg" alt="" />
<script>
jQuery(document).ready(function(){
jQuery('img').each(function(){
var error = false;
if (!this.complete) {
error = true;
}
if (typeof this.naturalWidth != "undefined" && this.naturalWidth == 0) {
error = true;
}
if(error){
$(this).bind('error.replaceSrc',function(){
this.src = "default_image_here.png";
$(this).unbind('error.replaceSrc');
}).trigger('load');
}
});
});
</script>