Quite simple...Thanks a lot!

Marco

Il giorno mercoledì 7 novembre 2012 17:07:03 UTC+1, asgallant ha scritto:
>
> Set the "type" parameter to "POST" and put your query in the "data" 
> parameter.  See the jQuery AJAX 
> documentation<http://api.jquery.com/jQuery.ajax/>for details.
>
> On Wednesday, November 7, 2012 6:22:39 AM UTC-5, Marco Megna wrote:
>>
>> Hi,
>> I use this script for acquire data from my sql DB with classic asp :
>> *data.asp*
>>
>>> <!--#include file="JSON_2.0.4.asp"-->
>>> <!--#include file="JSON_UTIL_0.1.1.asp"-->
>>> <%
>>> Set objConn = Server.CreateObject("ADODB.Connection")
>>> objConn.Open Application("Conn")
>>>         dim strsql
>>>         strsql="SELECT field1 FROM table_name"
>>> QueryToJSONobj(objConn, strsql).Flush
>>> %>
>>
>>  
>> and this to show the data:
>> *chart.asp*
>>
>>> <script type="text/javascript">
>>> google.load('visualization', '1', {'packages':['corechart','table']});
>>> google.setOnLoadCallback(drawChart);
>>> function drawChart() {
>>> var jsonData = $.ajax({
>>> url: "Data.asp",
>>> dataType:"json",
>>> async: false,
>>> success: function(){alert('OK');},
>>> error: function(responseText){alert('err: ' + responseText);}
>>> }).responseText;
>>> var data = new google.visualization.DataTable(jsonData);
>>> var table = new 
>>> google.visualization.Table(document.getElementById('chart_div2'));
>>> table.draw(data, {allowHtml: true, showRowNumber: true});
>>> }
>>> </script>
>>>
>>
>> everything works fine, but i want to improve it.
>> i have to do multiple queries, soI want to send the query to data.asp 
>> from chart.asp
>> The idea is that data.asp should become a dynamic page for retrieve any 
>> query  sent to it; something like:
>>
>> Set objConn = Server.CreateObject("ADODB.Connection")
>>> objConn.Open Application("Conn")
>>>         dim strsql
>>>         strsql=request("strsqlquery")
>>> QueryToJSONobj(objConn, strsql).Flush
>>
>>
>> one solution could be pass it from the url and use request.querystring:
>>  
>>
>>> var jsonData = $.ajax({
>>> url: "Data.asp" + "?strsql=" + encodeURIComponent("SELECT field1 FROM 
>>> table_name"),
>>> dataType:"json",
>>> async: false,
>>> success: function(){alert('OK');},
>>> error: function(responseText){alert('err: ' + responseText);}
>>> }).responseText;
>>
>>
>> it works, but there's a chars limit and with long complex queries doesn't 
>> work...
>> maybe with ajax it's possible to do something better...
>> any suggestion?
>>
>> Thanks!
>> Marco
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-visualization-api/-/Ru9prQ1Uep4J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to