81,122
社区成员




ReferenceError: jQuery17105408270653883338_1458090875372 is not defined
jQuery17105408270653883338_1458090875372({"name":"zhangsan"})
$.ajax({
url : url,
type:"POST",
dataType:"jsonp",
jsonp:"callbackParam",
async:false,
success:function(msg){
alert(msg+" "+"进来了");
//if(msg == "error"){
// alert(1);
//}else if(msg == "success"){
// alert(2);
// window.open(url,'NewWindow','height='+iHeight+',innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no,directories =no');
//}else{
// alert($("script",msg).html());
// alert($("script",msg).text());
//}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(XMLHttpRequest.status);
alert(XMLHttpRequest.readyState);
alert(textStatus);//parsererror
}
});
$.ajax({
type : "get",
async:false,
url : "http://localhost:8080/firstWeb/test",
dataType:"jsonp",//数据类型为jsonp
jsonp:"callback",//服务端用于接收callback调用的function名的参数
success:function(data){
$(".test").text("Result:"+data.key)
},
error:function(){
$(".test").text("Result:失败");
}
});
@ResponseBody
@RequestMapping("/test")
public String test(String callback) {
Map<String,String> map=new HashMap<String,String>();
map.put("key", "content");
JSONObject resultJSON = JSONObject.fromObject(map);
String res=callback+"("+resultJSON.toString(1, 1)+")";
System.out.println(res);
return res;
}
dataType:"jsonp",
jsonp:"callbackParam",
java后台,都有参数的呀
PrintWriter out = response.getWriter();
JSONObject res = new JSONObject();
res.put("d", "dddd");
String callbackParam = request.getParameter("callbackParam");//客户端请求参数
out.print(callbackParam + "({\"name\":\"zhangsan\"})");//返回jsonp格式数据
out.flush();
out.close();
[/quote]
callback参数和其他参数一样json格式,name:value,不要单独列出来
dataType:"jsonp",
jsonp:"callbackParam",
java后台,都有参数的呀
PrintWriter out = response.getWriter();
JSONObject res = new JSONObject();
res.put("d", "dddd");
String callbackParam = request.getParameter("callbackParam");//客户端请求参数
out.print(callbackParam + "({\"name\":\"zhangsan\"})");//返回jsonp格式数据
out.flush();
out.close();
function doPageMonitor(config) {
console.log("addon do page..." + JSON.stringify(config));
for (var m in config.monitors) {
m = config.monitors[m];
pageMod.PageMod({
include: m.urlPattern,
contentScriptWhen: "ready",
attachTo:["existing", "top", "frame"],
contentScriptFile: [self.data.url("jquery-1.7.1.js"), self.data.url("my-script.js")],
contentScriptOptions: {mConfig: m}
});
}
}