title: Simple jQuery, PHP and JSONP example?
body: <p>I am facing the same-origin policy problem, and by researching the subject, I found that the best way for my particular project would be to use JSONP to do cross-origin requests.</p>
  
  <p>I've been reading <a href="http://www.ibm.com/developerworks/library/wa-aj-jsonp1/" rel="noreferrer">this article from IBM about JSONP</a>, however I am not 100% clear on what is going on.</p>
  
  <p>All I am asking for here, is a simple jQuery>PHP JSONP request (or whatever the terminology may be ;) ) - something like this <strong>(obviously it is incorrect, its just so you can get an idea of what I am trying to achieve :) )</strong>:</p>
  
  <p>jQuery:</p>
  
  <pre><code>$.post('http://MySite.com/MyHandler.php',{firstname:'Jeff'},function(res){
      alert('Your name is '+res);
  });
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>&lt;?php
    $fname = $_POST['firstname'];
    if($fname=='Jeff')
    {
      echo 'Jeff Hansen';
    }
  ?&gt;
  </code></pre>
  
  <p>How would I go about converting this into a proper JSONP request? And if I were to store HTML in the result to be returned, would that work too?</p>