|
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
Techniques SQL Anywhere Server and AJAX
An AJAX call using stored procedures and web services
Aug. 19, 2009 09:45 AM
AJAX has dominated the web space so extensively that it needs no introduction. Connecting to a server via XMLHttpRequest and making a partial page refresh is what makes this technique so attractive. However, use of these AJAX requests, although very attractive, can pose dangers as well. JavaScript acts as a vector to infect websites with worms, such as SAMY, using cross-site scripting, also known as CSS or XSS.
Details of the AJAX Accessed Resource In the cited article the web service of type HTML called TestHtmlSvc retrieves a selected portion of the Customer's data from a table in the sample demo database. Note that the page can be called up by accessing this page at its URL, http://localhost:8080/demo/TestHtmlSvc. In this article an AJAX call will be made to access the same resource. To make such a call, an AJAX HTML page will be created and hosted on the same server so that the boundary of the browser security model isn't trespassed. Creating a Stored Procedure First, a stored procedure called Sabon is created on the SQL Anywhere Server as shown in Listing 1. Some of the HTML monitors the status of the call and information about the headers. Note that the getPage () function calls up http://localhost:8082/demo/TestHtmlSvc by making an XMLHttpRequest. The coding is quite straightforward but follows the same lines as in the article "Step by Step to AJAX." Simply stated, you create an XMLHttpRequest and access the resource by a GET method and then parse the response. The SQL Anywhere databases' HTTP Server is the SAWebServer used in the previous article. Figure 1 shows the stored procedures on this database including the Sabon stored procedure.
Figure 1 A Web Service to Call This Procedure
Figure 2 Figure 3 shows the web services on the SQL Anywhere server. Note that the web service Ajaxian is of type RAW, which needs no authentication with the DBA as user. Now this web service can be URL accessed as shown in Figure 4.
Figure 3 The AJAX Call
Figure 4 In essence, the Ajaxian web service calls up the Sabon stored procedure, which serves up the page containing an AJAX call to the SQL Anywhere Server to retrieve the TestHtmlSvc page. The XMLHTTPRequest's Headers, status, and state are shown in Figure 5, which is a screen capture of the displayed portion returned by the AJAX call.
Figure 5 Summary Reader Feedback: Page 1 of 1
Your Feedback
Latest Cloud Developer Stories
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week
Breaking Cloud Computing News
|
||||||||||||||||||||||||||||||||||||||||||||||||||||