SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    May 2008
    Missouri, USA
    0 Post(s)
    0 Thread(s)

    Jquery - Pipe Original Data to Ajax Fail event

    Hello, I have a scenario i'm trying to understand so I can implement it in my jquery code.

    I have a series of jquery ajax calls that use this function:
    callService = function(url,data){
    		var request = $.ajax({
    			url: url,
    			data: data,
    			dataType: "jsonp",
    			jsonp : "callback",
    			jsonpCallback: "jsoncallback",
    			error:function (xhr, ajaxOptions, thrownError){
    				DisplayError({error:thrownError, data});
    I use this function to async load multiple components in my ui. When I have a success everythings work perfectly because the response contains all the data I need. But, when "error" is triggered I run into a problem because it does not return any of the original data. I need the original data in order to associate the ajax call to a specific component in my ui.

    I found the pipe function in jquerys documentation and i'm trying to understand how to use it. What I would like to do is 'pipe' the data variable used in the ajax request into the error function. I'm a little confused on the syntax to do this and would appreciate some help or suggestions for better approaches.

    Thanks for your help.
    Follow Me On Twitter: BryceRay

  2. #2
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Sydney, Australia
    11 Post(s)
    0 Thread(s)
    It looks like you're trying to pass in a single value to an object without setting a key, you might want to try:

    Code javascript:
    DisplayError({error:thrownError, "data":data}); //note the key:value syntax
    var details = {
    . . web: "",
    . . photos: "",
    . . psa: ""


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts