RenComponent.JSONP

A JSONP component that supports both GET and POST methods.

It is FREE to use!!!

Why use this Component?

  • This component is JSONP-based, with which you can make cross-site request, so that you can make a set of websites work together.
  • This component implemented not only GET method, but also POST method, which can post a javascript object to server side.
  • This component not only support for stringified json format POST, but also XML or XHTML format POST.
  • This component can help to save your the trouble of to process concurrent requests.
  • This component can save more performance costs produced by DOM operations.
  • This component is passed the test under IE7 and FF3.

To use it:

  • STEP1. Download this component and the json2.js.
  • STEP2. Link both of them to your page.
<script type="text/javascript" src="json2.js"></script>
<script type="text/javascript" src="rencomponent.JSONP.js"></script>
  • STEP3. in your script, you can:
    • Get Data from JSONP Server (v1 b+)
// For v1.0.0 Beta1
// This is Client Javascript Code
// the url is the JSONP Server  URL
function CallJSONPServer(url)
{
       RenComponent.JSONP.Get(url);
}
// For v1.0.0 Beta2
// This is Client Javascript Code
// the url is the JSONP Server  URL
function CallJSONPServer(url)
{
       RenComponent.JSON.JSONP.Get(url);
}
  • Send Data to JSONP Server (v1 b+)
// For v1.0.0 Beta1
// This is Client Javascript Code
// the url is the JSONP Server  URL
// the postObject is an Javascript Object
function SendMyObjectToJSONPServer(url, postObject)
{
       RenComponent.JSONP.Post(url, postObject);
}
// For v1.0.0 Beta2
// This is Client Javascript Code
// the url is the JSONP Server  URL
// the postObject is an Javascript Object
function SendMyObjectToJSONPServer(url, postObject)
{
       RenComponent.JSON.JSONP.Post(url, postObject);
}
...
// This is Server C# Code
// get the stringified javascript object posted from Client through geting the value of key "postobj" from Request
       string postData=HttpContext.Current.Request["postobj"];
...
  • Convert javascript Objects to XMLDocument (v1 b2+)
var xmlDoc=RenComponent.JSON.JsonToXml(myObject);
  • Convert javascript Objects to XHTML (v1 b2+)
var tagName='span';
var myObject={...};
var domNode=RenComponent.JSON.JsonToHtml(tagName, myObject);

Feauture

  • Add support for appending a object to get/post method, so that it can join the response script execution. Then the code will look like this:
// This is call JSONP server code
RenComponent.JSON.JSONP.Get('you url', {'Value':1});
// The response code from JSONP server
alert(sender.Value);

Last edited Dec 28, 2008 at 5:27 AM by lchrennew, version 14