jQuery-Autocomplete icon indicating copy to clipboard operation
jQuery-Autocomplete copied to clipboard

Why the transformResult does not trigger

Open husm opened this issue 7 years ago • 2 comments

Hi,

I want to use transformResult to return the suggestions, but the transformResult does not trigger at all. I check in the Chrome log there is no log printed out, but in the network log I can see there is response from the server and the ajax is called successfully. I don't why, could you help me to figure out?

      $('#studentSchoolName').autocomplete({
        serviceUrl: '/api/v1/schools/search',
        ajaxSettings: {
          headers: {
            Accept: 'application/vnd.api+json',
            'Content-Type': 'application/vnd.api+json'
          },
        },
        method: 'GET', 
        dataType: 'jsonapi',
        transformResult: function(response) {
          console.log('------------response Dat', response);
          return {
            suggestions: responseData.data.map(item => item.attributes.name)
          };
        },
      });

husm avatar Mar 01 '18 12:03 husm

After debugging the code, I found that it is caused by the dataType - jsonapi

husm avatar Mar 01 '18 14:03 husm

DO YOU KNOW HOW MANY DAYS I'VE WASTED FOR THIS!. I was even following the documentation that says to use 'jsonp'. It's 'json' that actually works.

NevadaDonorNetwork avatar Aug 22 '18 17:08 NevadaDonorNetwork