Skip to content

Commit bb29f22

Browse files
committed
added examples to readme
1 parent ec22b3c commit bb29f22

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,69 @@ To run the code, cd to the directory where you checked out the code and type
1515

1616
node server.js
1717

18+
19+
API
20+
---
21+
22+
There are currently two commands:
23+
24+
###xml2jsonp - Convert an xml document to JSONP
25+
26+
####Example with CURL
27+
curl "http://your.node.installation.here/xml2jsonp?url=http://www.example.com/rss.xml&callback=myCallback"
28+
29+
####Example with HTML and jQuery
30+
<!DOCTYPE html>
31+
<html>
32+
<head>
33+
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
34+
<script type="text/javascript">
35+
36+
// This is the example XML file..
37+
var url = "http://www.example.com/rss.xml";
38+
39+
$("document").ready(function() {
40+
$.getJSON(
41+
"http://your.node.installation.here/xml2jsonp?callback=?&url=" + url,
42+
function(data) {
43+
alert(JSON.stringify(data, null, 4));
44+
}
45+
);
46+
});
47+
</script>
48+
</head>
49+
<body>
50+
</body>
51+
</html>
52+
53+
###jsonjsonp - Convert a JSON document to JSONP (handy for getting around cross-domain restrictions)
54+
55+
####Example with CURL
56+
curl "http://your.node.installation.here/json2jsonp?url=http://www.example.com/doc.json&callback=myCallback"
57+
58+
####Example with HTML and jQuery
59+
<!DOCTYPE html>
60+
<html>
61+
<head>
62+
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
63+
<script type="text/javascript">
64+
65+
// This is the example JSON file..
66+
var url = "http://www.example.com/doc.json";
67+
68+
$("document").ready(function() {
69+
$.getJSON(
70+
"http://your.node.installation.here/json2jsonp?callback=?&url=" + url,
71+
function(data) {
72+
alert(JSON.stringify(data, null, 4));
73+
}
74+
);
75+
});
76+
</script>
77+
</head>
78+
<body>
79+
</body>
80+
</html>
1881
Licence
1982
-------
2083

0 commit comments

Comments
 (0)