I'm having an issue which I'm dealing with for several hours and I can't figure it out how to access a value in php and return back to js.
This is my input field:
<input type="text" class="form-control input-lg" name="nr_ref" id="nr-ref"
placeholder="Ref"
data-parsley-group="step1"
data-parsley-trigger="change"
data-parsley-remote="validateit.php"
data-parsley-remote-options='{ "type": "POST", "dataType": "jsonp", "data": { "token": "value" } }'
required>
My validateit.php
is actually empty ;S
How to access the value of the input, so I can process it in my php file, and then return true / false displaying adequate message below the input element?
I'm loading both parsley-remote.min.js
and parsley.min.js
.
By default, Parsley in your above configuration would pass through POST
method the variable nr_ref
with the field value inside.
Basically, in your validateit.php
, if you make
<?php
die(var_dump($_POST));
then you should see this variable and its value passed by parsley to your script (in $_POST['nr_ref']
).
Feel free than to make your server-side checks and then return a 200 HTTP status code (with header()
) if successful or 4xx either.
Hope that helped you.
Best