title: Vue JS Ajax Calls
body: <p>I am trying to make the change from jQuery to Vue.js and am having some difficulty running an Ajax Call using vueresource. Below is a sample script I am using, with both jQuery and Vuejs. Both trying to access the same ajax call. The jQuery call works, the vuejs call doesn't. The sendAjax method is being called because the first 2 alerts show - then nothing.</p>
  
  <p>Edit - this is only causing an error while running the Ajax call through Wordpress. Outside of WP, it does work. Any ideas??</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Vue Resource&lt;/title&gt;
  
          &lt;script src="https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js"&gt;&lt;/script&gt;
          &lt;script src="https://cdn.jsdelivr.net/vue/latest/vue.js"&gt;&lt;/script&gt;
          &lt;script src="https://cdn.jsdelivr.net/npm/vue-resource@1.5.1"&gt;&lt;/script&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
          &lt;button id="jQueryAjax"&gt;Jquery AJAX&lt;/button&gt;
  
          &lt;div id="myvue"&gt; 
              &lt;button @click.prevent="sendAjax()"&gt;AJAX&lt;/button&gt;
          &lt;/div&gt;
  
          &lt;script&gt;
              let AjaxUrl = "http://localhost:8888/mySite/wp-admin/admin-ajax.php";
              const postData = { action: 'my_ajaxcall', function: 'AjaxTest' };
  
              Vue.use(VueResource);
  
              const ajax_app = new Vue({
                  el: '#myvue',
                  methods: {
                      sendAjax() {
                          alert("VueAjax");       
                          alert(JSON.stringify(postData));
  
                          this.$http.post(AjaxUrl, postData).then(res =&gt; {
                            alert(JSON.stringify(res));
                          });
                      }
                  }
              });    
  
              $("#jQueryAjax").click(function() {
                  alert("jQueryAjax");
                  alert(JSON.stringify(postData));
                  alert(AjaxUrl);
  
                  $.ajax({
                      type: 'POST',
                      url: AjaxUrl,
                      data: postData,
                      dataType: 'json',
                      success: function(data) {
                          alert(JSON.stringify(data));
                      },
                      error: function (xhr, ajaxOptions, thrownError) {
                          alert("Error");
                      }
                  });
              });
          &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>