Note that there are some explanatory texts on larger screens.

plurals
  1. POJSON encoded value not returned properly
    primarykey
    data
    text
    <p>I'm trying to call a file from my server and return an HTML form. I asked a question <a href="https://stackoverflow.com/questions/17136604/return-html-from-jquery-get-request">here</a> to get started but now I have another problem.</p> <p>The textbox and submit button display, but since the data is JSON encoded and returned via AJAX to a DIV I'm not quite sure how to approach it.</p> <p>Right now here's the result. Where I have "textbox and submit button" those elements are actually there. The other text appears around it.</p> <pre><code>testing {"formHTML":" "textbox here" " submit button here"&lt;\/form&gt;"} </code></pre> <p>Here's the code that would be on another server which calls to mine. This is the page that does the displaying</p> <pre><code>&lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" &gt;&lt;/script&gt; &lt;?php echo "testing"; ?&gt; &lt;script&gt; $.ajax({ type: 'GET', url: 'form_deliverer.php', data: "true", success: function(response) { // on success.. $('#yourdiv').html(response); // update the DIV } }) &lt;/script&gt; &lt;div id = "yourdiv"&gt; //form is displayed here &lt;/div&gt; </code></pre> <p>Here is the page that gets called, form_deliverer.php</p> <pre><code>&lt;? $o = new stdClass(); $o-&gt;formHTML = "&lt;form method='post'&gt;&lt;input type='textbox' name='text'/&gt;&lt;input type='submit' name='submit_text'/&gt;&lt;/form&gt;"; echo json_encode($o); ?&gt; </code></pre> <p>Because AJAX automatically updates the div, how can I decode the data? Should I even do that?</p> <p>For reference, this displays the form properly without the extra text. However, since I'll be calling from another server and have to deal with same domain issues, I'll have to use JSONP</p> <pre><code>&lt;? if(isset($_GET['true'])){ echo " &lt;form method='post'&gt; &lt;input type='textbox' name='text'/&gt; &lt;input type='submit' name='submit_text'/&gt; &lt;/form&gt; "; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload