title: calling function from php file inside javascript
body: <p>I have written this code to call a php function from javascript, the php function simply prints the arguments it receives, but this code is giving no output and nothing is printed, I am using google chrome browser, kindly help.</p>
  
  <p><strong>index.html</strong> file</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"&gt;&lt;/script&gt;
          &lt;script&gt;
              jQuery.ajax(
              {
                  type: "POST",
                  url: 'save.php',
                  dataType: 'json',
                  data: {functionname:'saveUser', arguments:["username", "password"]},
  
                  success: function (obj, textstatus) {
                      if( !('error' in obj) ) {
                          alert(obj.result);
                      }
                      else {
                          console.log(obj.error);
                      }
                  }
              });
          &lt;/script&gt;
      &lt;/head&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>save.php</strong> file</p>
  
  <pre><code>&lt;?php
  
      header('Content-Type: application/json');   
      if( $_POST['functionname'] == 'saveUser' ) {
          echo json_encode(Array(
              result =&gt; $_POST['arguments'][0] . ' ' . $_POST['arguments'][1]
          ));
      }
  
  ?&gt;
  </code></pre>
  
  <p><strong>output</strong>
  <a href="https://i.stack.imgur.com/tZ3nw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tZ3nw.png" alt="enter image description here"></a></p>