I have built a web application that accepts a Member_ID # from the client (javascript). The Member_ID is stored as a var in my javascript… now I need to make queries with it…first query to get member information (name) and then join tables to gather information for health plans that the member is elligible under … and so on.
As far as I can remember the concept is… send a async request to the server and wait for a response, once the response is received, store it and then parse it to extract useful information.
The end goal is to use the 'useful' information to plot graphs using HTML5 Canvas.
I need some direction with how to make the query? because when I read this forum, it is recommended that client-side query is 'bad' for a plethora of reasons.
Since most of my stuff is happening in the client side... few things in C# asp.net...how do I proceed?
It is also important to note that the web application should be accessible via the internet. outside the local network.
Does it make sense to Call a Web Service from the Client Side Using the AJAX Extension Toolkit??
You must handle it server side. Think about the ajax request as a simple POST or GET in the format of ?member_id=123&time=321 pointed at your handler file.
In your handler file you can construct your query from the request variables, execute it, and give a response by printing to the screen in either JSON or XML format.
Take a look here:
http://api.jquery.com/jQuery.ajax/
http://api.jquery.com/jQuery.getJSON/
Related
Hi I am new to google biqquery , so i want to make a POST method request to query big query table i am not aware where to pass the Query in the request so please help.
There are several ways to issue a query, but the short version is:
Get an OAuth access token (generally by using the gapi client).
Insert a query job.
Monitor for completion (a job may take a while to run, so you generally need to poll its status with a jobs.get operation).
Retrieve the results from the temporary table.
Inserting a query job can be done through this endpoint:
POST https://www.googleapis.com/bigquery/v2/projects/projectId/queries
The various REST endpoints are described in the public documentation here:
https://cloud.google.com/bigquery/docs/reference/v2/jobs/query#http-request
While you didn't describe your reason for doing this, I'll mention that consuming BigQuery directly is probably not something you want to do from a multi-user website (because each user would need to be a member of your project). You may be better off issuing queries and caching the results on the backend and providing your own frontend to render the results.
I am using XBMC json-rpc with websockets. When I send json request like "method":"Playlist.OnClear" I get response {"id":1,"jsonrpc":"2.0","result":"OK"}.
So if I'll send multiple requests I will get multiple responses and I won't be able to identify which response refers to which request. Is it possible to pass some additional data to request so that it would be added to response (like context in jquery ajax call)?
I don't know is it related to XBMC or json-rpc in general.
Perhaps this question was not answered because it is slightly inaccurate.
Firstly there is no method "Playlist.OnClear, rather Playlist.OnClear is only a non-solicited notification from the media player, on that states the playlist was cleared.
Now the playlist might clear directly as a result of another request you had made, for example Playlist.Clear comes to mind, which is indeed a method.
So when you send the valid json packet
{"jsonrpc":"2.0","method":"Playlist.Clear","params":{"playlistid":0},"id":10101}
You can use the "id" key to add a, guess what, an id to the request, and that very same id will be returned from the mediaplayer
{"id":10101,"jsonrpc":"2.0","result":"OK"}
Furthermore, it is possible to write paired web based requests/response code, but that's not even necessary considering the above...
I am developing an application that needs to gather information from GitHub, so I began looking at their API. My initial thought was to use the d3.json() function to get the data (because it's simple and has done good things for me in the past), but there doesn't appear to be a way for me to authenticate with that function. For example, $ curl -u "username" https://api.github.com is given as an example of basic authentication (from GitHub API--obviously they use curl for their examples).
So, is there a way to do authentication with the d3.json() function? And if not, what are my other options to get the JSON with JavaScript?
Thanks!
Edit:
I'm experimenting now with using jQuery's getJSON method as shown here, because I started getting the error "XMLHttpRequest cannot load url Origin url is not allowed by Access-Control-Allow-Origin." Of course, the switch doesn't help with the ability to authenticate, but I can at least get the public data (which is most).
Edit #2:
Has anyone experimented with michael/github or fitzgen/github-api? I'm going to start looking into those.
If you have a PHP script which echos JSON, you can do all authentication server-side. Note that you can also send a GET request to your PHP script, so the way you call your script can be dynamic.
I want to pass some textbox value strictly using POST from one html page to another...
how can this be done without using any server side language like asp.net or php
can it be done using javascript??
thnx
You can't read POST data in any way on javascript so this is not doable.
Here you can find similar questions:
http://forums.devshed.com/javascript-development-115/read-post-data-in-javascript-1172.html
http://www.sitepoint.com/forums/showthread.php?454963-Getting-GET-or-POST-variables-using-JavaScript
This reading can also be interesting: http://en.wikipedia.org/wiki/POST_%28HTTP%29
This expecially suggests why this answer (wikipedia is the source):
GET
Requests a representation of the specified resource. Requests using GET should only retrieve data and should have no other effect.
(This is also true of some other HTTP methods.)[1] The W3C has
published guidance principles on this distinction, saying, "Web
application design should be informed by the above principles, but
also by the relevant limitations."[10] See safe methods below.
POST
Submits data to be processed (e.g., from an HTML form) to the identified resource. The data is included in the body of the request.
This may result in the creation of a new resource or the updates of
existing resources or both.
POST data is added to the request. When you do a GET request the data is added to the url, and that's why you can access it through javascript (and that's why it's not parsed and you have to do it manually). Instead, POST send data directly into the http requests, which is not seen in any way by the html page (which is just a part of what is sent through the http request).
That said, only server side language will receive the full HTTP request, and definitely you can' access it by javascript.
I'm sorry but that is the real answer
I want to post some data via javascript to another domain. Something like:
http://www.othersite.com/submitfunnyname?name=blah
The other site (othersite.com) has a REST interface that you can call (well actually this is a get example) to submit a funny name to them.
Can I do this already with javascript? I'm a little confused on this - I know if that service wants to return some data, I'd need to use something like JSON-P - even though here I'm submitting some data, I guess the service will return some message structure letting me know the result, so it would have to be JSON-P, right?
Thanks
Not a particular expert in JavaScript, but isn't this an example of "cross-site scripting", which is not allowed due to possible security threats?
I believe you need to have all HTTP calls being made to the same server domain as the page. You could have a handler on your own site pass the information on to the othersite.com.
You can either use JSON-P if the site supports it, or you can use your web server as a proxy - by making requests to your server, which will in turn use a library such as cURL to make the actual request to the remote site.