2

here is my ajax request function

function get_from_rss(div_id , link_ ){
    jQuery.support.cors = true;
    $.ajax({
    url :  link_ ,  
        contentType: "application/json",
        dataType: 'jsonp',
        jsonp : "callback",
        jsonpCallback: 'callbackfunc'
    });
}

here is my callback function

function callbackfunc (data)
{
   // parse data
   // put them in the right div 
}

so the parsing part is similar for all of the links ( all links are json feeds from rss ) only thing different is that div , so i need to somehow send div id along with ajax result to callback function , otherwise i have to write separate callback function for each link

something like

   function callbackfunc (data , div_id)
    {
       // parse data
      $('#'+div_id).html(data);
    }
4

1 回答 1

1
function get_from_rss(div_id , link_ ){

    $.ajax({
        ...,
        jsonpCallback: function(data){
            callbackfunc(data, div_id);
        }
    });
}

你确定这是jsonpCallback你想要使用而不是success

于 2013-03-21T15:44:55.340 回答