Quantcast
Channel: sharepoint – Java && Linux
Viewing all articles
Browse latest Browse all 8

使用jquery获取 sharepoint restful web service(实例代码)

$
0
0

javascript本身的跨域问题是测试过程中遇到的主要问题,但是使用jquery可以很轻松的解决。

完整的代码如下

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Pragma" content="no-cache" />
	<title>Test MANS</title>
	<script type="text/javascript" src="jquery-1.8.3.min.js"></script>
</head>



<body>

</body>

<script type="text/javascript">

$(document).ready(function() {
	
	jQuery.support.cors = true;
	$.ajax( {
		url : "http://test.sharepoint/_vti_bin/listdata.svc/Test",
		async:true,
		dataType : "json",
		cache : false,
		success : function(data) {
			alert("f");
			if(data!=null && data.d!=null && data.d.results!=null){								
				$(data.d.results).each(function(i) {
					//alert(this.Code);
				});
			}
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
            alert("error: " + errorThrown);
        }
	});
});
</script>
	
</html>


Viewing all articles
Browse latest Browse all 8

Latest Images

Trending Articles





Latest Images