这个json格式没错啊但是回调函数不能执行解决方案

WBOY
Release: 2016-06-13 11:54:26
Original
1194 people have browsed it

这个json格式没错啊,但是回调函数不能执行

<br />[{"id":"4","type_name":"Galaxy Note2","sid":"v4"},{"id":"12","type_name":"Ascend P6","sid":"v12"}]<br />
Copy after login

这是生成的json格式的数据,格式没错啊

<br />//显示添加机型<br />function show_mobiletype(modelid,id) {<br />	$.getJSON("?m=content&c=content&a=mobile_getjson_ids&modelid="+modelid+"&id="+id, function(json){<br />		alert(json);<br />		var newrelation_ids = '';<br />		if(json==null) {<br />			alert('没有添加相关文章');<br />			return false;<br />		}<br />		$.each(json, function(i, n){<br />			newrelation_ids += "<li id='"+n.sid+"'>·<span>"+n.type_name+"</span><a href='javascript:;' class='close' onclick=\"remove_relation('"+n.sid+"',"+n.id+")\"></a></li>";<br />		});<br /><br />		$('#mobile_type_text').html(newrelation_ids);<br />	}); <br />}<br />
Copy after login


但是回调函数不执行。
------解决方案--------------------
alert(newrelation_ids);

没有问题,请检查其他地方
也应考虑是否是 BOM 头的影响
------解决方案--------------------
那只是因为你没有按规则调用方法

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template