Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>try with:</p> <p><strong>jQuery:</strong></p> <pre><code>$(document).ready(function(){ $.ajax({ url : 'index.php', dataType : "html",/* JSON, HTML, SJONP... */ type : "get", /* POST or GET; Default = GET */ data:{ keyword : "SOMEVALUE" }, success : function( response ) { console.log( response ) ; } }); }) </code></pre> <p><strong>PHP:</strong></p> <pre><code>&lt;?php if( array_key_exists( "keyword" , $_GET ) ) { if( !empty( $_GET["keyword"] ) ) { echo "&lt;p&gt;Woooow ajax!&lt;/p&gt;"; } } ?&gt; </code></pre> <p><strong>GET "SOMEVALUE" with PHP:</strong></p> <pre><code>echo $_GET["keyword"] </code></pre> <p><strong>GET "SOMEVALUE" with jQuery:</strong></p> <pre><code>data:{ keyword: $( "input" ).val() } </code></pre> <p><strong>OR USE PHP IN YOU JQUERY:</strong></p> <pre><code>&lt;?php if( array_key_exists( "keyword" , $_GET ) ) { $keyword = htmlentities ($_GET["keyword"],ENT_COMPAT,'UTF-8', true ); $keyword = str_replace("'","\'",$keyword); echo "var keywordValue = '" . $keyword."';" }else{ echo "var keywordValue = '';"; } ?&gt; data:{ keyword: keywordValue } </code></pre> <p><strong>And you code edited:</strong></p> <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(){ $( "#search" ).submit(function(){ /** * Send ajax */ $.ajax({ url : 'jquery2.php', dataType : "html",/* JSON, HTML, SJONP... */ type : "get", /* POST or GET; Default = GET */ data:{ keyword : $( self ).val() /* $(self) = $("#keyword") */ }, success : function( response ) { /** * Get Data and set on field2 */ $("#filter").val( response ) } }); /* prevent event */ return false; }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input type="text" name="keyword" id="keyword" /&gt; &lt;input type="hide" name="filter" id="filter" /&gt; &lt;input type="submit" value="Go!" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

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