Reputation: 173
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 the text 'bitcoin wallet after click' to it.
Instead of displaying it in an alert box like it does now, the variable in the PHP file that I want to display is $public
if that helps.
I've been sitting fiddling with the code for 3 hours now with no luck.
You can check how it works now on for better understanding.
<script>
$(function () {
$('#genbtn').one('click', function () {
var text = $('#wallet');
text.val(text.val() + ' bitcoin wallet after click');
});
});
</script>
and:
<script>
$.ajax({
url: 'addygen.php',
success: function (response) {
alert(response);
}
});
</script>
html:
<input type="text" id="wallet" maxlength="34" pattern="^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$"
placeholder="Your Bitcoin wallet's address"></input>
Upvotes: 0
Views: 105
Reputation: 1985
So, here where we are:
phpPage.php
, it works fineurl: '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");
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="wallet" maxlength="34" pattern="^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$" placeholder="Your Bitcoin wallet's address"/>
Upvotes: 2
Reputation: 173
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>
Upvotes: 0