<?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>call &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/call/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>on web development</description>
	<lastBuildDate>Tue, 13 Feb 2018 08:18:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.3</generator>
	<item>
		<title>jQuery &#8211; stop an ajax call!</title>
		<link>/2009/09/29/jquery-stop-an-ajax-call/</link>
		<comments>/2009/09/29/jquery-stop-an-ajax-call/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 17:33:30 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[call]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">/?p=741</guid>
		<description><![CDATA[It&#8217;s a simple task with no simple question, although in jQuery, as I mentioned now, everything is very simple. Even this task. In a short example we&#8217;ve a simple AJAX call with very large request. xhr = $.ajax({ url : 'www.example.com?some-large-call', success : function(responseText) { // some DOM manipulation } }); But what if something &#8230; <a href="/2009/09/29/jquery-stop-an-ajax-call/" class="more-link">Continue reading <span class="screen-reader-text">jQuery &#8211; stop an ajax call!</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2009/03/19/jquery-ajax-script-call/" rel="bookmark" title="JQuery ajax script call">JQuery ajax script call </a></li>
<li><a href="/2009/11/02/ajax-in-jquery/" rel="bookmark" title="$.ajax in jQuery">$.ajax in jQuery </a></li>
<li><a href="/2009/11/03/ajax-datatypes-in-jquery-format-and-access/" rel="bookmark" title="AJAX dataTypes in jQuery. Format and access.">AJAX dataTypes in jQuery. Format and access. </a></li>
<li><a href="/2009/10/22/event-driven-programming-with-jquery-part-3-what-is-a-module/" rel="bookmark" title="Event driven programming with jQuery &#8211; (part 3). What is a module?">Event driven programming with jQuery &#8211; (part 3). What is a module? </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>It&#8217;s a simple task with no simple question, although in jQuery, as I mentioned now, everything is very simple. Even this task.</p>
<p>In a short example we&#8217;ve a simple AJAX call with very large request.</p>
<pre lang="javascript">xhr = $.ajax({
    url : 'www.example.com?some-large-call',
    success : function(responseText) {
        // some DOM manipulation
    }
});</pre>
<p>But what if something changes the data we&#8217;d like to request with this call even before the response has come. For example I click on a category in the site but before all the data has come I&#8217;d prefer to see other category&#8217;s data.<span id="more-741"></span></p>
<p>In this case I just add some more code to the example. Actually it&#8217;s important to notice that $.ajax is returning an object that can be &#8220;aborted&#8221;.</p>
<pre lang="javascript">var xhr = null;

xhr = $.ajax({
    url : 'www.example.com?some-large-call',
    success : function(responseText) {
        // some DOM manipulation
    }
});

$(document).click(function() { xhr.abort() });</pre>
<p>As you can see this is really a mixture between working and pseudo code, so it will require a little bit more improvisation!</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2009/03/19/jquery-ajax-script-call/" rel="bookmark" title="JQuery ajax script call">JQuery ajax script call </a></li>
<li><a href="/2009/11/02/ajax-in-jquery/" rel="bookmark" title="$.ajax in jQuery">$.ajax in jQuery </a></li>
<li><a href="/2009/11/03/ajax-datatypes-in-jquery-format-and-access/" rel="bookmark" title="AJAX dataTypes in jQuery. Format and access.">AJAX dataTypes in jQuery. Format and access. </a></li>
<li><a href="/2009/10/22/event-driven-programming-with-jquery-part-3-what-is-a-module/" rel="bookmark" title="Event driven programming with jQuery &#8211; (part 3). What is a module?">Event driven programming with jQuery &#8211; (part 3). What is a module? </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2009/09/29/jquery-stop-an-ajax-call/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JQuery ajax script call</title>
		<link>/2009/03/19/jquery-ajax-script-call/</link>
		<comments>/2009/03/19/jquery-ajax-script-call/#respond</comments>
		<pubDate>Thu, 19 Mar 2009 05:45:52 +0000</pubDate>
		<dc:creator><![CDATA[stoimen]]></dc:creator>
				<category><![CDATA[featured]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[call]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">/?p=401</guid>
		<description><![CDATA[Learn how to include javascript files in your site via AJAX, using JQuery.<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2009/09/29/jquery-stop-an-ajax-call/" rel="bookmark" title="jQuery &#8211; stop an ajax call!">jQuery &#8211; stop an ajax call! </a></li>
<li><a href="/2009/11/03/ajax-datatypes-in-jquery-format-and-access/" rel="bookmark" title="AJAX dataTypes in jQuery. Format and access.">AJAX dataTypes in jQuery. Format and access. </a></li>
<li><a href="/2009/11/02/ajax-in-jquery/" rel="bookmark" title="$.ajax in jQuery">$.ajax in jQuery </a></li>
<li><a href="/2011/04/05/jquery-unbind/" rel="bookmark" title="jQuery.unbind()">jQuery.unbind() </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Many friends are asking me how to they use JQuery AJAX power. However you have two main ways, using:</p>
<blockquote><p><span style="color: #808080;">$(&#8216;#elem&#8217;).load(&#8216;url&#8217;, &#8221;, function() {});</span></p></blockquote>
<p>or</p>
<blockquote><p><span style="color: #808080;">$.ajax({</span></p>
<p style="padding-left: 30px;"><span style="color: #808080;">type : &#8216;GET&#8217;, // or POST</span></p>
<p style="padding-left: 30px;"><span style="color: #808080;">dataType : &#8216;text&#8217;, // or JSON</span></p>
<p style="padding-left: 30px;"><span style="color: #808080;">url : &#8216;url&#8217;, </span></p>
<p style="padding-left: 30px;"><span style="color: #808080;">data : {}, // GET or POST key/value parameters</span></p>
<p style="padding-left: 30px;"><span style="color: #808080;">success : function () {}, // on success callback</span></p>
<p style="padding-left: 30px;"><span style="color: #808080;">error : function () {} // on error callback</span></p>
<p><span style="color: #808080;">});</span></p></blockquote>
<p><em><span style="color: #333333;">Note: be careful to miss the comma after the error callback declaration, cause IE is giving some problems with objects with comma after the last key/value pair.</span></em></p>
<p>Both methods are useful, but however the second one is more complicated and gives more functionality. It&#8217;s important to note that if you&#8217;d like to include Html, which will be JavaScript processed after that, there are another two ways. The first one is obvious, you can call the javascript file processing the included Html in your success callback of the first ajax call. After calling the second ajax call, be aware to call it with dataType : &#8216;script&#8217;, which includes de js code and parses it as code. Than you can call whatever function in that .js as you&#8217;d do it as it was already included.</p>
<p>That method is obvious and easy, but however on slow nets it&#8217;s pretty slow and it&#8217;s not useful. Actually you can include your script file as you&#8217;d normally do it, with a script tag.</p>
<p>In it you should register all event listeners in methods you can call later. That&#8217;s the better way.</p>
<p>In the first case you have:</p>
<blockquote><p><span style="color: #333333;">$.ajax({</span></p>
<p style="padding-left: 30px;"><span style="color: #333333;">type: &#8216;GET&#8217;,</span></p>
<p style="padding-left: 30px;"><span style="color: #333333;">dataType: &#8216;text&#8217;,</span></p>
<p style="padding-left: 30px;"><span style="color: #333333;">url: &#8216;the_url&#8217;,</span></p>
<p style="padding-left: 30px;"><span style="color: #333333;">data: {},</span></p>
<p style="padding-left: 30px;"><span style="color: #333333;">success : function () {</span></p>
<p style="padding-left: 60px;"><span style="color: #333333;">$.ajax({</span></p>
<p style="padding-left: 90px;"><span style="color: #333333;">type: &#8216;GET&#8217;,</span></p>
<p style="padding-left: 90px;"><span style="color: #333333;">dataType: &#8216;script&#8217;,</span></p>
<p style="padding-left: 90px;"><span style="color: #333333;">url : &#8216;script.js&#8217;,</span></p>
<p style="padding-left: 90px;"><span style="color: #333333;">success : function() {</span></p>
<p style="padding-left: 120px;"><span style="color: #333333;">// now do what you want</span></p>
<p style="padding-left: 90px;"><span style="color: #333333;">}</span></p>
<p style="padding-left: 60px;"><span style="color: #333333;">})</span></p>
<p style="padding-left: 30px;"><span style="color: #333333;">},</span></p>
<p style="padding-left: 30px;"><span style="color: #333333;">error : function() {</span></p>
<p style="padding-left: 30px;"><span style="color: #333333;">}</span></p>
<p><span style="color: #333333;">});</span></p></blockquote>
<p>In the second case you&#8217;d just include your file:</p>
<blockquote><p><span style="color: #333333;">&lt;script src=&#8221;script.js&#8221;&gt;&lt;/script&gt;</span></p>
<p><span style="color: #333333;">&lt;script&gt;</span></p>
<p style="padding-left: 30px;"><span style="color: #333333;">$.ajax({</span></p>
<p style="padding-left: 60px;"><span style="color: #333333;">type : &#8216;GET&#8217;,</span></p>
<p style="padding-left: 60px;"><span style="color: #333333;">dataType : &#8216;text&#8217;,</span></p>
<p style="padding-left: 60px;"><span style="color: #333333;">url : &#8216;url&#8217;,</span></p>
<p style="padding-left: 60px;"><span style="color: #333333;">success : function() {</span></p>
<p style="padding-left: 90px;"><span style="color: #333333;">init_script(); // method in script.js</span></p>
<p style="padding-left: 60px;"><span style="color: #333333;">}</span></p>
<p style="padding-left: 30px;"><span style="color: #333333;">});</span></p>
<p><span style="color: #333333;">&lt;/script&gt;</span></p></blockquote>
<p>Now everything should work OK, good luck!</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2009/09/29/jquery-stop-an-ajax-call/" rel="bookmark" title="jQuery &#8211; stop an ajax call!">jQuery &#8211; stop an ajax call! </a></li>
<li><a href="/2009/11/03/ajax-datatypes-in-jquery-format-and-access/" rel="bookmark" title="AJAX dataTypes in jQuery. Format and access.">AJAX dataTypes in jQuery. Format and access. </a></li>
<li><a href="/2009/11/02/ajax-in-jquery/" rel="bookmark" title="$.ajax in jQuery">$.ajax in jQuery </a></li>
<li><a href="/2011/04/05/jquery-unbind/" rel="bookmark" title="jQuery.unbind()">jQuery.unbind() </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2009/03/19/jquery-ajax-script-call/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
