下面是該鏈接的示例代碼:
<!doctype html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width" />
<title>My App</title>
<script src="phonegap.js" type="text/javascript" charset="utf-8"></script>
<script src="jquery.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
$.ajax({
url:"http://www.ryanvikander.com/test.cfc?method=getdata",
success: function(data){
var content = $("#content");
content.html(data);
},
error: function(e){
console.log(e);
}
});
});
</script>
</head>
<body>
<div id="title_bar">Test</div>
This is a test
<div id="content"></div>
</body>
</html>
的網址http://www.ryanvikander.com/test.cfc?method=getdata
不必是任何比這更:
<cfcomponent>
<cffunction name="getdata" access="remote" output="false">
<cfreturn "Hello World!" />
</cffunction>
</cfcomponent>
這裏,success
回調函數將會把字符串"Hello World!"
分成<div id="content"></div>
如果功能renderdata()
返回查詢,您可以傳遞查詢字符串參數returnformat=json
和可選的queryFormat=column
以使ColdFusion將查詢數據轉換爲JSON。如果返回的數據使用JSON格式化,那麼您可以遍歷該數據以在任何網站中呈現HTML。
謝謝!一旦我將「access =」public「」改爲「access =」remote「」,它就起作用了。現在我可以從那裏去。 –
哎呀!修復了訪問值。 –