views:

721

answers:

3

I just recently started using jQuery on my classic ASP site. I am planning on rebuilding a page that has 4 sections and each section displays multiple rows and columns. JSON can help me here but all the examples that I have seen are VBScript related. This site is JScript and I am looking for some examples or tutorials using JSON, JScript and jQuery.

Thanks

+1  A: 

If I understand you correctly, you are using Javascript both server side (JScript) and client side (Javascript/JQuery) on an classic ASP site?

My advice would be to focus on client side development in JQUery, make few changes if possible on the server side (unless you're going to build a whole new WEB 2.0 app).

JScript should be able to parse JSON directly, and as far as I know, Javasctipt serialization code (see ww.json.org) should work in JScript as well, for passing data to the client. You can also build basic JSON data structures directly with simple Response.Write-s

goorj
Server side i am using JScript. For basic things i am using Response.Write and i even created a pipe | delimited string and passed back to the client side. Then created an array and used the information. But lets say i want to get the list of some clients and this information can have multiple rows and columns. I want to create an (array) object and using JSON pass it back to the client side and then display that. For this all the examples i have seen so far are done using VBscript as the server side. I am not sure or confused if JSON can be used with JScript for this. I need help here.
learning...
What you want is to create multidimensional arrays in JSON and pass it to the client, which can access it directly in Javascript. Ex:data = "({'row1' : ['one', 'two', 'three'], 'row2' : ['four', 'five', 'six'] })";mydata = eval(data);jQuery('#mydiv').html(mydata.row1[0]);To create the data, use response.write or you could serialize/"stringify" your JScript data structures using http://www.json.org/json2.js at the server side (should work with little modifications?)
goorj
A: 

On the client side, can utilize this example to get the JSON object from the server and utilize it. http://docs.jquery.com/Ajax/jQuery.getJSON

Using this example, on the client side i can build a JSON object and pass it to the sever utilizing JSON.stringify(JSONObject); http://ditio.net/2008/07/17/php-json-and-javascript-usage/

This page has the sample server side code using VBScript and the downloads page has the class available in VBScript to utilize it. http://code.google.com/p/aspjson/

For my app, on the server side, i can use eval to turn json string received into an object but that is not secure. http://www.json.org/js.html

For JScript, i have tried to but i am not able to find the equivalent to the 2 methods specified in the VBScript class or the class itself at the above location and these are stringify (converting JavaScript data structures into JSON text) and parse (to turn JSON text into object).

Still confused, need to rest and then start reading some more.

Got hold of a good tutorial using XML at SitePointForums. http://articles.sitepoint.com/article/ajax-jquery

I can either utilize the XML on my page or even turn the 4 items into 4 external pages and load these one by one (can show a loading message) when the page is ready.

$(document).ready(function() {
ShowPage("page.asp?clientID=12345&dataType=1", "1");
ShowPage("page.asp?clientID=12345&dataType=2", "2");
ShowPage("page.asp?clientID=12345&dataType=3", "3");
ShowPage("page.asp?clientID=12345&dataType=4", "4");
});

function ShowPage(url, id)
{
 $('#view'+id).html('');
 $.get(url,function(data){
    $('#view'+id).html(data);
    $('#loader'+id).hide(); //animated image, hide
    $('#view'+id).fadeIn();
 });
}
learning...