Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript get content from PHP
    primarykey
    data
    text
    <p>I am having a php page that take in a parameter e.g</p> <pre><code>mypage.php?keyword=SOMEVALUE </code></pre> <p>But the keyword is an ajax value that user enter at a html form which run with jQuery.</p> <p>I need to like let the user enter the value in a text field , and retrieve data from <code>mypage.php</code> and set it into the value of field1.</p> <p>How do I do it? I see that some site mention javascript respect same origin policy, what should I do?</p> <p>Now I got 2 files</p> <h3>UPDATED AGAIN</h3> <pre><code>&lt;!doctype html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;demo&lt;/title&gt; &lt;script src="http://code.jquery.com/jquery-1.9.1.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ $("#filter").click(function(){{ var self = this; //The following mostly from Olaf's answer $.ajax({ url : 'jquery2.php', dataType : "html",/* JSON, HTML, SJONP... */ type : "get", /* POST or GET; Default = GET */ data:{ keyword : $(keyword).val() /* $(self) = $("#keyword") */ }, success : function( response ) { /* * on input */ $("#keyword").val( response ) /* * on html */ $("#newhtml").html( response ) } }); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input type="text" name="keyword" id="keyword" /&gt; &lt;input type="button" id="filter" name="filter" value="Search Data" /&gt; &lt;div id="newhtml"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>jquery2.php</p> <pre><code>&lt;?php $keyword = $_GET['keyword']; echo "keyword is " . $keyword; ?&gt; </code></pre> <p>I changed my jquery.php to this code. but still fail to retrieve the output from jquery2.php , the textfield value does not change to jquery2.php output.</p> <p><strong>Thanks for helping</strong></p>
    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.
 

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