jQuery API

jQuery.get()

jQuery.get( url [, data] [, success(data, textStatus, jqXHR)] [, dataType] ) Returns: jqXHR

Description: Load data from the server using a HTTP GET request.

  • version added: 1.0jQuery.get( url [, data] [, success(data, textStatus, jqXHR)] [, dataType] )

    urlA string containing the URL to which the request is sent.

    dataA map or string that is sent to the server with the request.

    success(data, textStatus, jqXHR)A callback function that is executed if the request succeeds.

    dataTypeThe type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html).

This is a shorthand Ajax function, which is equivalent to:

$.ajax({
  url: url,
  data: data,
  success: success,
  dataType: dataType
});

The success callback function is passed the returned data, which will be an XML root element, text string, JavaScript file, or JSON object, depending on the MIME type of the response. It is also passed the text status of the response.

As of jQuery 1.5, the success callback function is also passed a "jqXHR" object (in jQuery 1.4, it was passed the XMLHttpRequest object). However, since JSONP and cross-domain GET requests do not use XHR, in those cases the (j)XHR and textStatus parameters passed to the success callback are undefined.

Most implementations will specify a success handler:

$.get('ajax/test.html', function(data) {
  $('.result').html(data);
  alert('Load was performed.');
});

This example fetches the requested HTML snippet and inserts it on the page.

The jqXHR Object

As of jQuery 1.5, all of jQuery's Ajax methods return a superset of the XMLHTTPRequest object. This jQuery XHR object, or "jqXHR," returned by $.get() implements the Promise interface, giving it all the properties, methods, and behavior of a Promise (see Deferred object for more information). For convenience and consistency with the callback names used by $.ajax(), it provides .error(), .success(), and .complete() methods. These methods take a function argument that is called when the request terminates, and the function receives the same arguments as the correspondingly-named $.ajax() callback.

The Promise interface in jQuery 1.5 also allows jQuery's Ajax methods, including $.get(), to chain multiple .success(), .complete(), and .error() callbacks on a single request, and even to assign these callbacks after the request may have completed. If the request is already complete, the callback is fired immediately.

// Assign handlers immediately after making the request,
  // and remember the jqxhr object for this request
  var jqxhr = $.get("example.php", function() {
    alert("success");
  })
  .success(function() { alert("second success"); })
  .error(function() { alert("error"); })
  .complete(function() { alert("complete"); });

  // perform other work here ...

  // Set another completion function for the request above
  jqxhr.complete(function(){ alert("second complete"); });

Additional Notes:

  • Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, or protocol.
  • If a request with jQuery.get() returns an error code, it will fail silently unless the script has also called the global .ajaxError() method. Alternatively, as of jQuery 1.5, the .error() method of the jqXHR object returned by jQuery.get() is also available for error handling.
  • Script and JSONP requests are not subject to the same origin policy restrictions.

Examples:

Example: Request the test.php page, but ignore the return results.

$.get("test.php");

Example: Request the test.php page and send some additional data along (while still ignoring the return results).

$.get("test.php", { name: "John", time: "2pm" } );

Example: pass arrays of data to the server (while still ignoring the return results).

$.get("test.php", { 'choices[]': ["Jon", "Susan"]} );

Example: Alert out the results from requesting test.php (HTML or XML, depending on what was returned).

$.get("test.php", function(data){
alert("Data Loaded: " + data);
});

Example: Alert out the results from requesting test.cgi with an additional payload of data (HTML or XML, depending on what was returned).

$.get("test.cgi", { name: "John", time: "2pm" },
   function(data){
     alert("Data Loaded: " + data);
   });

Example: Gets the test.php page contents, which has been returned in json format (<?php echo json_encode(array("name"=>"John","time"=>"2pm")); ?>), and adds it to the page.

$.get("test.php",
   function(data){
     $('body').append( "Name: " + data.name ) // John
              .append( "Time: " + data.time ); //  2pm
   }, "json");

Support and Contributions

Need help with jQuery.get() or have a question about it? Visit the jQuery Forum or the #jquery channel on irc.freenode.net.

Think you've discovered a jQuery bug related to jQuery.get()? Report it to the jQuery core team.

Found a problem with this documentation? Report it on the GitHub issue tracker

  • http://elis.ws/ Eli

    If I’m doing something like this:

    function example () {
    var value = ”;

    $.get(‘url’, function (data) {
    process data;
    value = data.something;
    });

    return value;
    }

    the returned value of the example function is ”, because it was returned /before/ the new value was set using the $.get function.

    how can I avoid it? I want the value to be returned only after the $.get function has finished it’s thing.

    Thanks.

    • http://profiles.yahoo.com/u/BT55ZXB46U7N5D66WU27TWYJ2Y Hyponiq

      Expanding on carlo:
      Essentially, you would use an anonymous function to get the result of the request. Example:
      var value = (function () {
          var val = null;

          $.ajax({
              'async': false,
              'global': false,
              'url': 'path/to/url.php',
              'success': function (data) {
                  val = data;
              }
          });

          return val;
      })();

      While this solution would suffice, there are a multitude of different ways to go about it. This is the simplest way (that I have found).

    • Anonymous

      Short answer: you can’t, without making the UI lock up.
      Just think what happens if for some reason the url you are getting failed to respond – server outage etc – your code would hang, waiting for a response that isn’t coming (and in doing so would stop any of your other js from running).

      Instead of trying to change something based on the example functions result, you can change that thing in the callback which is passed to $.get.
      This avoids the above issue with your code locking up.

  • AreN

    You should add a note about the XMLHttpRequest parameter beeing added in 1.4

  • http://angler.wordpress.com/ Martin W. Angler

    Hello,

    I keep getting a “Permission denied” error when using jQuery 1.4′s $get() to access an (external) url. Trying to create a RSS reader.

    Any ideas?

    Thanks a lot in advance!

    • http://thingswellmade.com/ Julian

      Hi Martin that's because of SOP http://en.wikipedia.org/wiki/Same_origin_policy. Inside an ordinary web page you cannot access URLs from other domains. That's why all the examples don't have http:// in the front. Wasn't the clearest I agree.

      The only web page on the internet that can allow this is the background page of a Google Chrome Extension. Maybe its worth thinking about writing an extension instead? http://code.google.com/chrome/extensions/xhr.html

      Alternatively you can write a server-side element which your client accesses. There is no restriction on where content can be obtained on your server-side.

      • http://angler.wordpress.com/ Martin W. Angler

        Thanks a lot!

        Or perhaps writing a piece of code on our side which then in turn accesses the “foreign” pages could do the trick.

        However, I will definitely have a look at your proposed solution, for sure!

        Thanks again and best regards,
        Martin

    • http://www.thalent.nl/ Michiel Thalen

      XmlHttpRequest are not allowed to access external urls by the brower. There is nothing you or jquery can do. Maybe in new versions it will be implemented

    • http://www.bjornjohansen.no/ Bjørn Johansen

      As a security feature of Javascript you can not access external resources with ajax. You need to create a local proxy, like a PHP file containing the following:<?php readfile('http://&#039; . $_GET['url']);Then you can get the contents by using an url like yourproxyfile.php?url=externalurl

  • http://www.freedomeditor.com/ Bart B

    Just a little tip since i learned this the hard way:

    var=$.get(‘url’, function (data) { return data;});
    alert (var);
    doesn’t work as i (and possibly others) did expect. It returns “XMLhttpobject”, while alert(data) inside the callback function does work as expected.

    var=$.get(‘url’, function (data) { array[]=data;});
    works, but any functions defined before the .get succeeded, fail at accessing the array. Even if the actual function execution is performed on a later stage. Solution is (i hope, am about to test) to send the array or variable explicitely to that function on execution, like function(array_var).

    • Anonymous

      Bart

      There’s a easy way to do what you want, but you need to use .ajax not .get/.load/.post :

      var return_value= $.ajax({ type: “GET”, url: “myfunction.php”, async: false }).responseText;

      (A) make sure you set async to false – this makes the call synchronous, which means the value is returned from the server call right away. Not necessary for typical UI updates, etc., but often need for seamless, predictable flow where you need to interact with the server and avoid having a bunch of nested callback functions.

      (B) notice .responseText at the end of the call. This conveniently extracts the text from the object that is returned.

      Since it looks like you’re looking for an array coming back, I’d probably just convert to JSON on the server side and unpack the returned string into an array.

      Discovering this ajax call cleaned up my code a lot, because it allows you to get return values from the server side function call in the way you would naturally expect ala other programming languages instead of having to use callbacks to handle returned values.

      Sadly, I have entire books on jQuery that never get around to mentioning this and treat all calls to the server as if they have to be asyncronous and handled by callbacks.

      In my case, I was doing some cleanup in a beforeunload event handler, and because some of that cleanup was on the server, firebug was showing that the php call appeared to hang (even though it did what it was supposed to do). The problem was that doing it asynchronously, by the time php called me back, the calling page was already unloaded. By changing the call as shown here, the function call returned control to javascript and I retained control of the program flow.

      Hope this helps, it sure helped me alot.

      Dave

      • Anonymous

        This helped me immensely – my challenge was in how to pass the result of an ajax request to a variable. I couldn’t figure out how to do it with the success: callback function. Thanks, Dave. The async: false and .responseText is key.

      • Zach Hynes

        Dave,

        Thanks a lot! You solved a control flow problem I’d been struggling with for a while, where my server would sometimes seem to return data, and sometimes would seem to return the empty string. Setting async: false fixed this problem for me.

        I really appreciate you taking the time to comment and help us poor novice coders out.

        Cheers,
        Zach

      • gengar

        thanks Dave, you saved my day !

    • http://www.freedomeditor.com/ Bart B

      My last claim might be false, any functions defined before the .get with callback array defining, succeeded, probably are able to access changed array data. It’s been too long so i’m not 100% sure.

  • http://www.enchanter.net/ Brian Kendig

    There is a significant ‘gotcha’ with jQuery.get():

    INTERNET EXPLORER WILL CACHE THE RESULTS.

    If your code works in Firefox but you notice that in IE your AJAX call always seems to be returning the same exact response even though you’re using different arguments, this is the problem. Easiest solution: change your jQuery.get() to a jQuery.post(). See “http://www.sitecrafting.com/blog/ajax-ie-caching-issues/” for more details.

    • Sebastien Cyr

      To prevent caching with any browser when using any method, simply add a unique request id as a parameter.

      i.e. $.get('_ajax.php?rid=123456789');

      The browser will see this as a different file and request a fresh copy.

      • italianPlumber

        How do I generate a unique request ID?

        • Craig

          The unique request ID just has to be any kind of value. If you want just get the current time from javascript (it returns a time stamp in milliseconds) when creating the link. While this technically isn’t fool proof, it is extremely unlikely that someone would be able to load your page, click the link, let the result load, reload the page, and try to click the link again all within the same millisecond.

      • broox

        this is bad if you’re also doing caching on the server side as your server side cache would always have a different URL that would never get called again… it’s best to use the ajaxSetup method or just user jquery’s ajax() method in place of get() and set cache to false.

    • Tom

      try $.ajaxSetup({cache: false}).

      • Simon

        This achieves the same as what Sebastien suggests below, although I prefer the ajaxSetup method for clean-ness. For an ajax request I am using, the server log records this URL being served up:

        /r/unlock/39/?_=1275999348505

        The ?_=1275999348505 part was added automatically by jQuery, and is unique each time.

  • fil

    I am missing details:
    o syntax/objtype to specify data
    o exact definition of callback parameters: types, semantics
    o handling of callbacks return value
    o possible values of dataType and their effect
    o what is returned?

  • Jesse

    THIS IS BROKEN FOR ARRAYS: It should be

    $.get(“test.php”, { 'choices': ["Jon", "Susan"]} ); // NOTE missing []

    • Anonymous

      I have to pass an array of String similar to the above but it does not work with or without []

      • T. Ganoe

        If you want to pass a string (payload) up to the server, use $.post

        the http get request may work for uploading values but jquery $.get doesn’t

  • Sajeethan

    how can put content from a php file in a div?

    • Hgabka

      $('#divid').load('myphp.php',{'par1' : 'value1', 'par2' : 'value2'});

      This will load the returned content from myphp.php into the div with id divid.

  • Tomas

    Hello, I am trying:

    $.get(“?do=loadData”, {“value”: value, “phase”: phase}, function(data) {
    alert(data);
    });

    but doesn't work :(
    Do anybody know, where is the failure?
    (I don't use jQ.. neither JS, so I'm noob in this)

    • Hgabka

      In the first parameter you have to provide an URL, not a parameterlist, or whatever you mean by '?do=loaddata'.
      Like:

      $.get('loaddata.php', {“value”: value, “phase”: phase}, function(data) {
      alert(data);
      });

      where loaddata.php exists on the server, handles the parameters value and phase and echos the desired content (that you want to get by '$.get(…))

      • Tomas

        well, thanx for help. But I solve it moment before :)
        ?do=loadData is request above current web page, where 'do' is variable and loadData parameter.
        But my fault was not here. It was in PHP script on server.
        in script was: echo 'something';
        and correct for alerting message is: echo “'something'”;
        double ” plus simple '
        Thanx

  • Laureno

    I have a problem with IE.
    In FF and Chrome it's working, but I have error and no action in IE (all IE: IE6, IE7, IE8).
    Can You help me?

    $(“.dlzb”).each( function() {
    $(this).click( function() {
    $.get( 'http://el.indecity.nstrefa.pl/pl-lista-dodaj,1,1.html&#39; );
    } );
    } );

    • http://jpaulino.pip.verisignlabs.com/ Josep

      You can only call .get on the domain you're in so you could do this:

      $(“.dlzb”).each( function() {
      $(this).click( function() {
      $.get( '/pl-lista-dodaj,1,1.html' );
      } );
      } );

      as long as you're the script is run on domain: http://el.indecity.nstrefa.pl/

  • ANi

    i am getting a return datatype of get/post method is html. and in html data if i get two “div” out of which i want to replace only one div with my current form div using $(' ').html(data). is it possible with that? please give me a suggestion for this. Waiting.

    thank u

  • Gast

    Hej,
    I try to find a way to use JQuery Ajax within my project but struggle with the PHP functions.
    This is basically what I want to do:
    I have a collection of PHP functions in a separate file and some functions even need an input. Like returnName( $var)…
    What would be a clever solution? I don't want to split my PHP Function collection into several smaller files (each function a php file, right?) and even don't have a clue how to hand $var over…

    • Uttam

      echo script to php than run php.ini file

    • Kelleyburrus

      i also have same problems with Gast …
      did anyone can help??

  • chand

    its nice but i want t get data from of query from success parameter and assign it to php loop function so it can show all the result

    • Jules Colle

      I think best practice here would be write the loop-function in the page you call trough ajax, so the data you get back is already in the correct format for html output

  • john

    what's jquery ajax codes if you want to load all changes automatically without refreshing it? The concept is just like a chat…

  • Ck_ronin86

    Hi everyone!
    I'm trying to use this method to get a XML with Chrome and it doesn't work cause it seems like and empty file when I call a trace on the callback function.
    As i explained my code is:

    $(document).ready(function(){
    $.get(“info.xml”, procesaXML)
    })

    function procesaXML(info){
    alert(info)
    }

  • Ufoundmetony

    does anybody know how to load a specific content and not an entire web page when using the jQuery.get below?

    $.get('filename.html', function(data) {
    $('.class_name').html(data);
    });

    • lwpro2

      you might wanna wrap data as jquery object, then load only the requested part of the object.

    • http://twitter.com/oscargodson Oscar Godson

      You'd do:
      $.get('filename.html', function(data) {
      $('.class_name',data).html(); //returns the HTML of .class_name inside of filename.html
      });

      • Ufoundmetony

        don't know what happened to my earlier comment that I just made, but I was elaborating more on the issue.

        The filename.html which has content tag names like “[Copyright Year] that goes in the footer position of the site gets dynamically generated.

        I've created another static page help.html that has pretty much the same content overall except the dynamic content won't get loaded with the content tag (the system doesn't allow static pages to load them). This is what brought me to this solution. So now that I've added a class name to the indicated class that I want to load it pulls all the content and styling of the site rather than just the dynamically generated content of (filename.html) .

        Sample code that I made in the help.html

        <div class=”adp_footer”>[Copyright Footer]</div> <—- Doesn't get loaded when I used any of the above mention jquery strings,

        How come?

        • http://www.learningjquery.com/ Karl Swedberg

          Your earlier comment was probably removed because we're trying to keep comments focused and on topic. We would appreciate it if you could direct your questions and requests for help to the jQuery forum at http://forum.jquery.com/. Thanks.

    • http://twitter.com/ctide Chris Burkhart

      didn’t see the response

  • Schwarzenneger

    This is my code:

    $.get(“/ajax-terms.asp”, function(d){
    $(“#somediv”).html(d);
    })

    The terms page contains characters such as ‘ and ’ which appear correctly on the page if embedded directly via server side code, but with AJAX strange symbols such as � (question marks) appear. Why so? Any workaround?

    • http://www.learningjquery.com/ Karl Swedberg

      It probably has to do with ajax data always being sent as utf-8. I suspect that your data is using the iso-8859-1 charset. Others have already asked on the forum ( http://forum.jquery.com/ ), so you might be able to find an answer there.

    • Jesse

      Make sure that your character encoding is set the same on the sending page as it is in the ajax-terms.asp page. More than likely you don’t have it set in the ajax-terms.asp page. look into the charset and content-type headers.

  • Randy

    Anyone else having problems with $get using Safari 5?
    This works in IE 8 but not Safari 5?:

    function grabXml(){

    $.get(“test.xml”, processResult);

    }

  • http://www.ciseur.net S. Alixant

    I use $.get() to load a .jpg before displaying it.
    In FF and Chrome, everything is fine.
    In IE, it' doesn't work.
    $.get('imgs/image.jpg',function() {
    $('img').attr('src','imgs/image.jpg');
    });
    I tried with .gif or other file (.php, .html) it works. But I still got a problem with .jpg.

  • Workdavidg

    HI, I'm using jquery to load a CSV file. This is the part of the script where i load the data.

    $.get(
    'data.csv', function(data) {
    // Split the lines
    var lines = data.split('n');
    ….
    and then I use the lines in my script. Someone knows why dont work fine???

    • Workdavidg

      Only it doesn't work in Chrome, at FF and IE it works

  • Workdavidg

    HI, I'm using jquery to load a CSV file. This is the part of the script where i load the data.

    $.get(
    'data.csv', function(data) {
    // Split the lines
    var lines = data.split('n');
    ….
    and then I use the lines in my script. Someone knows why dont work fine???

  • Workdavidg

    HI, I'm using jquery to load a CSV file. This is the part of the script where i load the data.

    $.get(
    'data.csv', function(data) {
    // Split the lines
    var lines = data.split('n');
    ….
    and then I use the lines in my script. Someone knows why dont work fine???

  • Workdavidg

    HI, I'm using jquery to load a CSV file. This is the part of the script where i load the data.

    $.get(
    'data.csv', function(data) {
    // Split the lines
    var lines = data.split('n');
    ….
    and then I use the lines in my script. Someone knows why dont work fine???

  • Fghjfghj

    tzu

  • Ibahhc

    How to pass arrays of data to the server with it's key also preserved?

    Eg:-

    array(“fname” => “chhabi”, “lname” => “pachabhaiya”);

    • Andreas

      convert to object

  • Gawrrell

    Hy, i have a php file, inside this file is

    but when im calling the like this

    var gaw;
    gaw =$.ajax({type:”GET”,url:”PHPfile.php”});
    alert (gaw);

    it return ” [object] ”

    Why ? How can i reslove it ?

    Thanks

    • Jakub S.

      probably with this:
      gaw =$.ajax({type:”GET”,url:”PHPfile.php”}).responseText;

  • http://www.qdmeiyu.com Zfqd2010

    第一次用汉语发表一下对jquery的喜欢,刚开始学习。

  • Wallace

    HTTPS and IE8 issue:

    Here's a note for anyone who runs into this problem. If you're calling .get() (and presumably $.ajax(), etc) on an https URL and you're using IE8, it will fail unless you specify a content type in the response header… (such as text/plain or text/javascript if using JSON)

    We just spent a morning trying to figure out why a single line of text wasn't being passed back when using IE8 (only on the secure side) when it worked fine in Firefox and IE8 on http. IE8 on https would make the call, see a response, and not get any of the content of the response.

    Annoying.

    • Dustin Oprea

      As a follow-up to this, if you're AJAXing a file that ends with the “json” extension and, most likely, any file that renders a content-type of 'application/json', the browser may/will interrupt the call if the file is poorly formatted, even though it remains unparsed when it comes back to JQuery.

  • http://www.seslidizayn.com Seslidizayn

    güzel

  • nyqa

    When I try to use jquery ajax with .NET master pages I get the whole HTML page returned from a single .ashx file that returns one word and nothing else!

    Why is this? Why does ajax return the whole pages HTML code?

    • Ephekt

      Possibly because you're returning a fully rendered page (layouts). In rails, you specify the return type to be html json xml etc, you may want to look at the .Net controller specifications and let your controller know that you will be receiving a xhr request and to only return the contents of the file, not the full rendered layout. Hope this helps — it's nabbed me a few times.

    • http://twitter.com/mustafaarun mustafa arun

      you have to clear page content and write your result then end response like:
      Response.Clear();
      Response.ClearContent();
      Response.ClearHeaders();
      Response.Write(“result”);
      Response.End();

  • Lalit Patel

    Hi I am using php.
    I have 2 div with unique id and i get content on it with Jquery.get sometimes 1st div data comes in 2nd div and 2nd div data in 1st div.

    What is solution of this problem. Please answer me.

  • me

    somescrit.php:
    echo('garbage');
    ?>

    index.php:
    <div id=”code”></div>
    $('#code').load('http://localhost/somescript.php&#39 ;) ; this isn't work in 'security shit context' i don't understand why

  • Dustin Oprea

    As a follow-up to this, if you're AJAXing a file that ends with the “json” extension and, most likely, any file that renders a content-type of 'application/json', the browser may/will interrupt the call if the file is poorly formatted, even though it remains unparsed when it comes back to JQuery.

  • Devlshone

    Can $.get return an array?

  • Raghunv

    Hi ,
    I am having a weird issue.. In the original request which is post I Create a file in the server. In the call back I open a popup and attempt to download the file ..I am able to download the file in non IE browsers but not able to do it in IE … Can you tell me how do i address this issue..

    • http://javakafunda.blogspot.com Yogesh gandhi

      Can you please send me the file, how did you achieve this using ajax.

      Actually I have a requirement that there is a zip file on the server which is sent in the response when a particular action is invoked.

      I want that when that action is invoked via ajax, the returned content shows the user a popuup to save that file anywhere he likes. But that is not coming, as the request goes in the background. Or I am using it in a wrong manner.

      I tried http://www.filamentgroup.com/l…/

      But that is also not workign for me.. :(

      Can you please tell me, how did u achieve this

      My e-mail : yogesh249@gmail.com

  • jc

    im confuse can you tell me whats is the main difference between $.ajax() and $.get()

    • cs

      $.get is just a shorthanded form of $.ajax specifically for dealing with HTTP GETs.

  • Fee

    qqd123网址之家,http://www.qqingdou.com/,人们都在用的电脑主页!

  • Jq-primaryNavigation

    jq-primaryNavigation

  • Bucki

    // I like jelly and php.

    print “I like Jelly”;
    ?>

    • Aaaaaaa

      aaaaaaa

  • Guest

    I want to send content-type in request header while calling Ajax url.
    Its going as a request parameter, not as a request header.
    Please help.

  • http://twitter.com/frops Asanov Il’dar

    How to hide from the user php file, which is transmitted GET-request???

    • http://twitter.com/daemonfire juls foi

      No possibility to do so. Otherwise you have to use FLEX / Flash solution with SSL so even sniffing won't be possible.
      HTTP is as open as possible, you can not “hide” such things.
      Only workaround would be encrypting different things so it isn't obvious on first sight, that you access “xload.php”

  • Guest

    Hi All,

    Please help me with sending 'content-type' in jQuery.get().
    I have found that by default 'application/x-www-form-urlencoded' will be sent through request.
    Even the default value I am not able to see in my code when I try to print 'ContentType' in request.

    Thanks in Advance.

  • leavetheherd

    OK, I got lost somewhere In this code, from the first example in the documentation,

    $.get('ajax/test.html', function(data) {
    $('.result').html(data);
    alert('Load was performed.');
    });

    Lets say I want to insert the html from the external file in a <div> on the page. How do I do that? </div>

    • Franquis

      Hi!
      $('#myDiv').html(data) will insert the var data (the html from 'ajax/test.html') in the div “myDiv”…

      Otherwise, have a look on the load() function…
      i.e. $('#myDiv').load('ajax/test.html');

  • Yogesh gandhi

    I am doing this….

    function downloadFileAndRefreshCart(downloadUrl) {
    $.get(
    url: downloadUrl,
    function(data) {
    // Now that we executed the action corresponding to the downloadUrl
    // Just reload myself (i.e. the iframe)
    self.location.reload();
    }
    );
    }

    But…what is happening is, it is able to download the file, but it doesn't asks the user, where to save the downloaded file, it saves in a temporary location.

    How do I do this? so that the downloaded file is visible on the browser where it is getting saved.

  • http://twitter.com/pydevil pydevil

    Hi guys,
    i want to get string in the middle of circle:
    http://www.magick.cz/spiral/ho…
    what method i should use? … load()? get()? ajax()?
    i'd tried many ways but without success =(

  • Saud Prakash

    hi, i am new to jquery, i made a get request like this $.get(“get_items_by_simplesearch.php”,{search_for:”",near_place:”"} ,
    function(result){ $(“.right_section_block”).html(result); }); only the text is rendering, the bing image of the get_items_by_simplesearch.php page is not rendering, can some one help me please.

  • http://www.learningjquery.com/ Karl Swedberg

    If you make the request with $.get() and it returns an error code, it fails silently unless you call the global .ajaxError() method. So, either use .ajaxError() in conjunction with $.get() or use $.ajax() with an error callback.

  • http://dalelarsen.com Dale Larsen

    I agree. I just do something like this:

    url + '?undoCache=' + Math.random()

  • Ajimon KS

    Hi ,
    I am using ajax for pagination and below code is working correctlly in all browser (F.3.6, IE8,Safari & Chrome,Opera)

    code:
    ——————————————–
    var params = {'page':page , 'row':rowp,'query':''}; //parameter array
    $.ajax({
    type:”GET”
    ,url: '<your url >'
    ,data:params
    ,cache:false
    , success: function(data,status) {
    $(“#u_l”).html(data);
    }
    ,error:function (xhr, ajaxOptions, thrownError){
    alert(xhr.status);
    alert(xhr.statusText);
    alert(thrownError);
    }
    ,complete: function (XMLHttpRequest, textStatus) {
    // var headers = XMLHttpRequest.getAllResponseHeaders();
    }
    ,beforeSend: function(xhr){
    //xhr.setRequestHeader('Accept', 'text/html');
    //xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
    //xhr.setRequestHeader('Access-Control-Allow-Methods', 'POST');
    }
    }
    );
    ——————————————–

    Hope this will help to solve your problem

    Ajimon KS