How To Add Variable From Php Into A Form Using A Button With Jquery?
I have these two codes that I want to combine into one, so when I click the genbtn it will add the response from the PHP file into the 'wallet' form like the function below adds th
Solution 1:
So, here where we are:
- When I used the following code with a local
phpPage.php
, it works fine - When I put the
url: 'http://www.ubit.ca/addygen.php'
the developer tool showed me the following error:
the connexion used to get resources not encrypted
So I think that he problem is whith your permission to acces to the http://www.ubit.ca/addygen.php
file.
$.ajax({
url: 'http://www.ubit.ca/addygen.php',
ifModified: true,
dataType: 'text',
success: function(data){
$("#wallet")
},
error:function(){
alert("error");
}
});
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><inputtype="text"id="wallet"maxlength="34"pattern="^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$"placeholder="Your Bitcoin wallet's address"/>
Solution 2:
here's a code snippet of the solution:
<script>
$(function() {
$('#genbtn').one('click', function() {
$.ajax({
url: 'addygen.php',
success: function(response) {
var text = $('#wallet');
text.val(response);
}
});
});
});
</script>
Post a Comment for "How To Add Variable From Php Into A Form Using A Button With Jquery?"