Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Could try something like this</p> <pre><code>$(document).on('change', '#value', function() { $.post('/validation.php', {validate_year:$("#Year").val(), validate_value:$("#value").val(), validate_domain$("#Domain").val()}, function(data) { //Take the output of validation.php and put them into a class or id target $(".target-area").html(data); } }); </code></pre> <p>Basically what is happening is that the $.post function is reaching out to a URL that you specify, in this case validation.php. I am guessing that you are trying to return something to the javascript file that indicates whether something is valid or not. So for example</p> <pre><code>//valiation.php &lt;?php $validate_year = $_POST['validate_year']; $validate_value = $_POST['validate_value']; $validate_domain = $_POST['validate_domain']; //Do something here to determine if it is valid or not //If the result is $valid in this pseudo code example if($valid) { echo 'true'; } else { echo 'false'; } </code></pre> <p>In this example, the PHP script is returning a value of true or false based on the checks that you made against a database, expected results, etc, etc to the posted variable, in this case it is returned as the <code>data</code> variable in javascript.</p> <p>So if you did something like this,</p> <pre><code>$(document).on('change', '#value', function() { $.post('/validation.php', {validate_year:$("#Year").val(), validate_value:$("#value").val(), validate_domain$("#Domain").val()}, function(data) { //Take the output of validation.php and log it to the console console.log(data); } }); </code></pre> <p>You would see the <code>true</code> or <code>false</code> result from the validation.php file I wrote. You probably want to return something to notify the user whether or not the validation failed or succeeded. So to expand on this, say you had a div on your page setup like this</p> <pre><code>&lt;div id="validation-result"&gt;&lt;/div&gt; </code></pre> <p>Your javscript would interpret the response from validation.php and output something to the user ... like this</p> <pre><code> $(document).on('change', '#value', function() { $.post('/validation.php', {validate_year:$("#Year").val(), validate_value:$("#value").val(), validate_domain$("#Domain").val()}, function(data) { //Take the output of validation.php, parse it and update the page if(data == 'true') { var content = "Your validation succeeded"; } else { var content ="Your validation failed"; } $("#validation-result").html(content); } }); </code></pre> <p>And the final result on your page would look like this for true</p> <pre><code>&lt;div id="validation-result"&gt;Your validation succeeded&lt;/div&gt; </code></pre> <p>or this for false</p> <pre><code>&lt;div id="validation-result"&gt;Your validaiton failed&lt;/div&gt; </code></pre> <p>Hope that help clears up the answer a little bit for you</p>
    singulars
    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.
    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