Reply
Thread Tools
Posts: 289 | Thanked: 101 times | Joined on Oct 2009
#1
I am currently doing a program for a site which need me to run a certain javascript. The script do I get from a HTTP 200 response. My problem is that I have never done javascripting so I do not really know how this works, I could guess that you would use the QScriptEngine to process it.

But the bigger problem I have is that when I get the response with the script and runs it, it should try to communicate with the server. This is becuase in the <script type="text/javascript"> there is a function filter which looks like this:

Code:
function filter() {
var query = "userId=11111&daysBack=" + $("#daysBack").val();
$("#chartContainer").load("/statistics/typedistributionchart?" + query);
}
I have been running wireshark to see all the packets thats being transmitted/recieved. But all I see is a ACK and then nothing more. So what I think is that this $("#chartContainer").load() stuff is already on my computer. But if so how do I access this and what datatype is it??

Yours,
 
Posts: 560 | Thanked: 422 times | Joined on Mar 2011
#2
Are these scripts designed to be run on Maemo or even mobile devices? This isn't really a js forum but everyone round here will help where we can.

I'm unsure what you want anyone to do. Please would you re-ask your question(s) in a really simple way so it's clear what you want
- say what the situ is, in each case
- describe the expected outcome
- describe the actual outcome
- reiterate what you want help with, including any ideas you have for the problem.
Doing it in this neo-bug-report way means you'll get a result quickly.

Last edited by demolition; 2011-04-05 at 22:36.
 

The Following User Says Thank You to demolition For This Useful Post:
Posts: 237 | Thanked: 193 times | Joined on Feb 2010 @ Brighton, UK
#3
Originally Posted by Lullen View Post
But the bigger problem I have is that when I get the response with the script and runs it, it should try to communicate with the server. This is becuase in the <script type="text/javascript"> there is a function filter which looks like this:

Code:
function filter() {
var query = "userId=11111&daysBack=" + $("#daysBack").val();
$("#chartContainer").load("/statistics/typedistributionchart?" + query);
}
I have been running wireshark to see all the packets thats being transmitted/recieved. But all I see is a ACK and then nothing more. So what I think is that this $("#chartContainer").load() stuff is already on my computer. But if so how do I access this and what datatype is it??

Yours,
Looks like fairly standard JavaScript JQuery running in a browser :
var query
is a dynamically built string where
$("#daysBack").val()
is most likely the value inputted or held in the html form element with 'id="daysBack"'

$("#chartContainer").load("/statistics/typedistributionchart?" + query);
is then calling the url query and displaying the returned HTML in a visual element with an 'id=chartContainer'

If I were you I'd look at what:
http://THE_SITE/statistics/typedistr...111&daysBack=2
returns, assuming a valid user ID of course.

Does it return HTML? Will you need to parse out the bits you want from this markup? Does the site offer a cleaner way of getting this data?
 

The Following User Says Thank You to mr id For This Useful Post:
Posts: 289 | Thanked: 101 times | Joined on Oct 2009
#4
@Demolition: I know this is not a js forum but I am building the app in Qt and it will be for maemo/meego

Originally Posted by mr id View Post
Looks like fairly standard JavaScript JQuery running in a browser :
var query
is a dynamically built string where
$("#daysBack").val()
is most likely the value inputted or held in the html form element with 'id="daysBack"'

$("#chartContainer").load("/statistics/typedistributionchart?" + query);
is then calling the url query and displaying the returned HTML in a visual element with an 'id=chartContainer'

If I were you I'd look at what:
http://THE_SITE/statistics/typedistr...111&daysBack=2
returns, assuming a valid user ID of course.

Does it return HTML? Will you need to parse out the bits you want from this markup? Does the site offer a cleaner way of getting this data?
From http://THE_SITE/statistics/typedistr...111&daysBack=2 I do get back a HTML file. That is the one containing the script. What is happening when I send the http://THE_SITE/statistics/typedistr...111&daysBack=2 to the server (from browser) is that i get a pop-up with a pie diagram wich shows me how much, in percent, I have been doing each training type.

here is a picture

I was in contact with the site owner before and his real api was quite limited to his own apps which were limited too. So this is the only way to go.

I figured out how to save the packets to a txt file so here is the packets from GET to response. After this packets a new GET comes(which was me changing daysBack).
http://pastebin.com/YjJ7Db27

Hope you guys understand this now!

Yours,
 
Posts: 237 | Thanked: 193 times | Joined on Feb 2010 @ Brighton, UK
#5
The site is returning the javascript conifguration for building the diagram in a library called Highcharts. The necessary js includes for this library will likely be at the top of html page that first loads. Look for highcharts.js or similar, it's a great charting library but does it run in Qt?

You could parse out the dataset and draw the charts yourself of course. Lmk if it wasn't clear to you where that data is.
 
Posts: 289 | Thanked: 101 times | Joined on Oct 2009
#6
Thanks, I will look into it!
I did not mean the site was running Qt but my application that need the charts does
 
Posts: 237 | Thanked: 193 times | Joined on Feb 2010 @ Brighton, UK
#7
Originally Posted by Lullen View Post
Thanks, I will look into it!
I did not mean the site was running Qt but my application that need the charts does
Fully understand that, sorry if it wasn't clear. If the charting doesn't run in your app you'll need to parse out the values and render the chart yourself.

cheers
 
Reply


 
Forum Jump


All times are GMT. The time now is 09:01.