title: Compare ids from a ajax function and define multiple ids
body: <p>I am working with the following script:</p>
  
  <pre class="lang-js prettyprint-override"><code>&lt;script&gt;
  $(document).ready(function(){
  
      $('#postJson').click(function(){
  
          // show that something is loading
          $('#response').html("&lt;b&gt;Loading response...&lt;/b&gt;");
  
          /*
           * 'post_receiver.php' - where you will pass the form data
           * $(this).serialize() - to easily read form data
           * function(data){... - data contains the response from post_receiver.php
           */
          $.post('post_receiver.php', { user_id: "143", username: "ninjazhai", website: "http://codeofaninja.com/" }, function(data){
  
              // show the response
              $('#response').html(data);
  
          }).fail(function() {
  
              // just in case posting your form failed
              alert( "Posting failed." );
  
          });
  
          // to prevent refreshing the whole page page
          return false;
  
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <pre class="lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;jQuery post JSON data using .post() method by codeofaninja.com&lt;/title&gt;
  
      &lt;/head&gt;
  &lt;body&gt;
  
  &lt;h1&gt;jQuery post JSON data using .post() method&lt;/h1&gt;
  &lt;div&gt;Click the button below to get response.&lt;/div&gt;
  
  &lt;!-- our form --&gt;  
  &lt;input type='button' value='Post JSON' id='postJson' /&gt;
  
  &lt;!-- where the response will be displayed --&gt;
  &lt;div id='response'&gt;&lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  
  
  <p>How can if for #postJson several other ids? I could with [id^=p] but then id are not defined.</p>
  
  <p>And how can I compare that Id to use more data like </p>
  
  <pre><code>user_id: "143", 
  username: "ninjazhai", 
  website: "http://codeofaninja.com/ 
  </code></pre>
  
  <p>to not use the same script several times? like </p>
  
  <pre><code>if (#ida== #ida) {abc: "123", def: "456", ghi: "kdlkds"}
  </code></pre>
  
  <p>Script is from <a href="https://www.codeofaninja.com/2013/09/jquery-ajax-post-example.html" rel="nofollow">here</a>.</p>
  
  <p>Or is this a PHP job? But do I have to us the same code 100,000 times?</p>