Reputation: 3543
I am new in Android Hybrid App. I want post token in ajax request and Get ajax response.
My Webview is here
In This webview 3 field post by ajax from php side but I want when click on SUBMIT button with this 3 field i want to post token from my side.
So how can i post token with this post request and also how can get Response of this request.
This is my ajax Function:
$("#submit").click(function () {
$.ajax({
url: 'http://localhost/php_site/insertUserData',
method: "POST",
dataType: 'json',
data: $("#form").serialize(),
success: function (result) {
console.log(result);
},
error: function () {
console.log("error");
}
});
});
Above ajax post request code implemented in php file loaded in Android webview.
I try to find but can't get exact solution please help me if anyone know this. Thank you.
Upvotes: 2
Views: 1367
Reputation: 62421
You may have to post your token
as parameter of POST
request. For that you may have to create PHP file instead of HTML file.
like:
www.yoururl.com/functionName.php
with post parameter token
which will be get by PHP file and make one hidden field to store it.
So your form will automatically post token by clicking on SUBMIT button.
I think it will be a better solution. If you find any then happy to know. :) :)
Thank you.
Upvotes: 1