Body: <p>I am fighting since days with this situation:</p>
  
  <p>I have a Select field with around 150 item and depending on a selected item a list of icons and names should be shown (around 50). The list of items (names and an url for an icon) comes from an API.</p>
  
  <p>I am calling this API withing the variable component of a plugin. I have to do it with PHP, AJAX API call is not possible in my case. 
  So right now I am putting the whole content in a string and spitting that string out in twig. Resulting in a 37,6 MB document. So this is not the solution...</p>
  
  <p>My thought is now to return an array of the API in my variable component and grab just the DATA I need on the change event of the select field.</p>
  
  <p>Is that possible? Can I use the include statement of twig with AJAX? Or grab data from the variable in the plugin with JS?</p>
  
  <p>I am really not getting forward with this and it's driving me mad !</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-29T22:39:03.633Z
Comments.Text: Do I understand correctly and your API returns ~40 MB worth of text?
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-30T09:40:15.960Z
Comments.Text: No, just the string I returned in the variable component was that big. But as I thought, this was nonsense, just to picture the desperateness of my situation. However I found a better way now. Will post an answer soon.
Comments.UserDisplayName: Jan
Tags: <plugin-development><ajax><include>
Title: Include with AJAX
ThreadText: # Include with AJAX
  
  (Asked by: username_0 on 2017-08-26)
  
  I am fighting since days with this situation:
  
  I have a Select field with around 150 item and depending on a selected item a list of icons and names should be shown (around 50). The list of items (names and an url for an icon) comes from an API.
  
  I am calling this API withing the variable component of a plugin. I have to do it with PHP, AJAX API call is not possible in my case.
  So right now I am putting the whole content in a string and spitting that string out in twig. Resulting in a 37,6 MB document. So this is not the solution...
  
  My thought is now to return an array of the API in my variable component and grab just the DATA I need on the change event of the select field.
  
  Is that possible? Can I use the include statement of twig with AJAX? Or grab data from the variable in the plugin with JS?
  
  I am really not getting forward with this and it's driving me mad !
  
  **Tags:** plugin-development, ajax, include
  
  > **Comments:**
  > **username_1**: Do I understand correctly and your API returns ~40 MB worth of text?  
  > **username_0**: No, just the string I returned in the variable component was that big. But as I thought, this was nonsense, just to picture the desperateness of my situation. However I found a better way now. Will post an answer soon.  
  
  ---
  
  ## 0 answers
  
  