ITeye博客

jquery ajax 跨域

taoshi · 2014-10-29 14:42 · jquery ajax 跨域 · Web前端 · Markdown


function testRemote(){
	 $.ajax({
			type : "get",
			async:false,
			url : "http://192.168.30.36:8080/JavaScriptTools/remoteServlet",
			data: {
				timeStamp: new Date().getTime(),
				password:"123456",
				loginName:"changchao"
			},
			dataType : "jsonp",
			jsonp: "callbackparam",//服务端用于接收callback调用的function名的参数
			jsonpCallback:"success_jsonpCallback",//callback的function名称
			success : function(json){
				alert(json);
				alert(json[0].name);
			},
			error:function(){
				alert('fail');
			}
		});
 		}



response.setContentType("text/html");
		
		String callbackFunName = request.getParameter("callbackparam");
		
		response.getWriter().print(callbackFunName + "([ { 'name':'john'}])");
		
		response.getWriter().flush();
		
		response.getWriter().close();


评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。