<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SoftLayer Blog &#187; AJAX</title>
	<atom:link href="http://blog.softlayer.com/tag/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.softlayer.com</link>
	<description>A Behind the Scenes Look at the Best Hosting Provider in the World</description>
	<lastBuildDate>Wed, 15 May 2013 15:33:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<item>
		<title>API Basics: REST</title>
		<link>http://blog.softlayer.com/2011/api-basics-rest/</link>
		<comments>http://blog.softlayer.com/2011/api-basics-rest/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 14:55:37 +0000</pubDate>
		<dc:creator>Kevin Trachier</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SoftLayer]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[JSONP]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/2011/</guid>
		<description><![CDATA[What is REST? &#8220;Representational State Transfer,&#8221; or REST, is a style of software architecture designed to relate different types of hypermedia to each other for distribution. The basic concept of REST is that a client application can request information from a server in the form of a representation of a resource without actually downloading an [...]]]></description>
			<content:encoded><![CDATA[<p><strong>What is REST?</strong><br />
&#8220;Representational State Transfer,&#8221; or REST, is a style of software architecture designed to relate different types of hypermedia to each other for distribution. The basic concept of REST is that a client application can request information from a server in the form of a representation of a resource without actually downloading an entirely new resource. This is how the World Wide Web works.</p>
<p><strong>The World Wide Web</strong><br />
A browser is a client side application which requests information from a server; the server then accepts the request and transfers data back to the browser. The data transferred is not an application; it simply gives instructions to the client-side application (the browser), which then uses those instructions to properly display some information. Downloading information from a server changes the <a href="http://en.wikipedia.org/wiki/State_%28computer_science%29">application state</a> of the browser. The result of that change in state is a new website, which is therefore named the new state, so when new websites are downloaded by a browser, it is transferring representational data for a new application state.</p>
<p><strong>How does REST relate to SoftLayer&#8217;s API?</strong><br />
<a href="http://sldn.softlayer.com/wiki/index.php/The_SoftLayer_API">SoftLayer&#8217;s API</a> has many different avenues for implementation; one of these avenues is simple data transfer using the <a href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods">GET</a> method in <a href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol">HTTP</a>. <a href="http://en.wikipedia.org/wiki/Hyperlinks">Hyperlinks</a> are one of the most basic examples of REST in action. When the user clicks on the hyperlink it requests information from the server and responds by transferring back representational data, in this case the data is expressed as either <a href="http://en.wikipedia.org/wiki/XML">XML</a> or <a href="http://en.wikipedia.org/wiki/JSON">JSON</a>.</p>
<p><strong>What are the disadvantages of using a REST API?</strong><br />
REST requests must contain all information, including authentication, within the <a href="http://en.wikipedia.org/wiki/Uniform_Resource_Locator">URL</a>. This can lead to security threats somewhere down the line. Luckily, SoftLayer allows you to add any number of users to your account, and then restrict their access to specific servers/services. This way your customers can utilize SoftLayer&#8217;s API without a security risk to you or each other. They can even create their own users and further restrict access.</p>
<p><strong>What are the advantages of using SoftLayer&#8217;s REST API?</strong><br />
Direct client to server communication is the biggest advantage of using REST. The other protocols that SoftLayer uses to communicate data to the API require server-side scripting; this means that you will have to program your websites to use the host server as a proxy for calling SoftLayer functions. With REST you can directly link to the information that you want to display, using <a href="http://en.wikipedia.org/wiki/XLST">XLST</a> or <a href="http://en.wikipedia.org/wiki/JavaScript">JavaScript</a> to display it. You can also use <a href="http://en.wikipedia.org/wiki/Ajax">AJAX</a> with <a href="http://en.wikipedia.org/wiki/JSON#JSONP">JSONP</a> or <a href="http://blog.softlayer.com/2011/ajax-without-xml-http-requests/">script injection</a> to dynamically update your webpage.</p>
<p><strong>REST</strong><br />
The REST archetype is the most natural API for HTTP. This sets it above others in that there are no secondary programs needed to interact with HTTP (like <a href="http://blog.softlayer.com/2011/api-basics-what-is-soap/">SOAP</a>), which means less computing time and better performance. REST APIs also don&#8217;t need to use a proxy server for remote procedure calls. This decreases server load and bandwidth usage and further increases website performance. SoftLayer&#8217;s REST API is easy to implement, and with SoftLayer&#8217;s tiered user system its security flaws can be eliminated. This is why I prefer SoftLayer&#8217;s REST API over the others.</p>
<p>Basic REST function calls are detailed in the SoftLayer Development Network (SLDN) <a href="http://sldn.softlayer.com/wiki/index.php/REST#REST_URLs">here</a>.</p>
<p>-Kevin</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2011/api-basics-rest/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AJAX Without XML HTTP Requests</title>
		<link>http://blog.softlayer.com/2011/ajax-without-xml-http-requests/</link>
		<comments>http://blog.softlayer.com/2011/ajax-without-xml-http-requests/#comments</comments>
		<pubDate>Wed, 19 Jan 2011 16:00:03 +0000</pubDate>
		<dc:creator>Kevin Trachier</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[efficiency]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/2011/</guid>
		<description><![CDATA[What is AJAX? Asynchronous JavaScript and XML &#8211; AJAX &#8211; is what you use to create truly dynamic websites. Ajax is the bridge between application and presentation layers, facilitating lightning fast, instant application of data from the end user to the host and back to the end user. It dynamically changes the data displayed on [...]]]></description>
			<content:encoded><![CDATA[<h3>What is AJAX?</h3>
<p><a href="http://en.wikipedia.org/wiki/Ajax">Asynchronous JavaScript and XML</a> &#8211; AJAX &#8211; is what you use to create truly dynamic websites. Ajax is the bridge between application and presentation layers, facilitating lightning fast, instant application of data from the end user to the host and back to the end user. It dynamically changes the data displayed on the page without disrupting the end user or bogging down the client. Although the name is misleading, it is used as a term for any process that can change the content of a web page without unnecessarily reloading other parts of the page.</p>
<h3>What are XML HTTP requests?</h3>
<p>Passing information from your server to your end user&#8217;s browser is handled over <a href="http://en.wikipedia.org/wiki/HTTP">HTTP</a> in the form of <a href="http://en.wikipedia.org/wiki/HTML">HTML</a>. The browser then takes that info and formats it in a way the end user can view it easily. What if we want to change some of the data in the HTML without loading a whole new HTML document? That&#8217;s where XML comes in. Your web page needs to tell the browser to ask for the XML from the server; luckily, all browsers have a function called <code><a href='http://en.wikipedia.org/wiki/XMLHttpRequest'>XmlHttpRequest()</a></code>. Once it&#8217;s called, it will poll the server for XML data.</p>
<h3>Why shouldn&#8217;t you use XML HTTP requests?</h3>
<p>A long time ago, in a galaxy far, far away, Microsoft invented the <code>XmlHttpRequest()</code> object for Microsoft Exchange Server 2000. As with all first generation technologies, everyone wanted to use it, and some people implemented it differently. IE didn&#8217;t even have native support until 2006, and there are still some discrepancies in various browsers when studying the <code><a href="http://en.wikipedia.org/wiki/XMLHttpRequest#The_onreadystatechange_event_listener">OnReadyStateChange</a></code> event listener. There is also an issue with <a href="http://en.wikipedia.org/wiki/XMLHttpRequest#Cross-domain_requests">cross-domain requests</a>. When the internet was young, JavaScript hackers would steal users&#8217; identity by pulling information from secure websites and posting it to their own, stealing bank account numbers, credit cards, etc. Now that the internet has grown up a bit, people with large networks and many servers have found use for sending data across domains, but it&#8217;s still not possible with XML HTTP requests.</p>
<h3>What&#8217;s an Alternative?</h3>
<p>Using JavaScript, you can create client side scripts whose source is built with server side scripts, passing variables in the URL. Here&#8217;s an example of a basic web page with local JavaScript, a few checkboxes for human interaction, and a table with some information that we want to change. View source on the page <a href="http://64.246.2.254/Examples/example.html">below</a> to see the outline.</p>
<p><iframe src="http://64.246.2.254/Examples/example.html"></iframe><br/></p>
<p>Looking at the three JavaScript functions, the first (<code>clearTags</code>) automatically clears out the checkboxes on load, the second (<code>check(box)</code>) makes sure that only one box is checked at a time, the third (<code>createScript</code>) is the interesting one; it uses the <code>createElement()</code> function to create an external JavaScript, the source of which is written in PHP. I have provided a sample script below to explain what I mean. First, we get the variable from the URL using the <code>$_GET</code> super global. Then, we process the variable with a switch, but you might use this opportunity to grab info from a database or other program. Finally, we print code which the browser will translate to JavaScript and execute.</p>
<div style="width: 650px; height: auto; overflow:auto; border: 1px solid black;">
<pre><code>&lt;?PHP
//First we get the variable from the URL
$foo=$_GET['foo'];
//Here's the switch to process the variable
switch ($foo){
case 'foo' : print "var E=document.getElementById('data'); E.innerHTML='bar'; "; break;
case 'fooo' : print "var E=document.getElementById('data'); E.innerHTML='barr'; "; break;
case 'ffoo' : print "var E=document.getElementById('data'); E.innerHTML='baar'; "; break;
case 'ffooo' : print "var E=document.getElementById('data'); E.innerHTML='baarr'; "; break;
default : print "var E=document.getElementById('data');
E.innerHTML='unknown'; ";
}
?&gt;
</code></pre>
</div>
<p>-Kevin</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2011/ajax-without-xml-http-requests/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
