title: How can I update my AJAX settings from within an AJAX call?
body: <p>I am writing a chat application and want to get settings for all subsequent AJAX calls in the first chat call.</p>
  
  <p>I set the default jQuery AJAX settings:</p>
  
  <pre><code>jQ.ajaxSetup({
    url : 'chat.php',
    contentType: 'application/json'
    dataType : 'json',
    type : 'post'
  });
  </code></pre>
  
  <p>Then I pass the action to return a JSON object containing the data to connect to the specific chat.</p>
  
  <pre><code>jQ.ajax({
    data: {
      'action' : 'connect'
    },
    success: function (data) {
      if (data.success) {
      // set user ID and chat ID for all subsequent ajax calls
        if (data.partner) {
        // start fetching data to listen for messages
        } else {
        // keep checking for partner
        }
      } else {
      //  chat connect failed
      }
    }
  });
  </code></pre>
  
  <p>If the chat is created and the user is connected to a chat partner, Every 0.2 seconds I fetch data from the server like so:</p>
  
  <pre><code>setTimeout(fetchData, 200);
  function fetchData(){
    jQ.ajax({
      data: {
        'action' : 'fetch'
      },
      success: function (data) {
        if (data.success) {
          // update messages
        }
        setTimeout(fetchData, 200);
    });
  }
  </code></pre>
  
  <p>I also have AJAX functions to post data and disconnect from the chat, and basically they will all need to have the same chat credentials as set by the initial 'connect' action.</p>
  
  <p>What would be the best way to achieve this?</p>