call a stored proc
Hi I'm trying to find my first steps in php_crud, which is quite self explenatory. I was also trying this php-sp-api which I could not understand how to use it. I will appreciate any explanation, Regards and thanks Eli
Here is a simple JavaScript code that worked for me.
var divResult = document.getElementById("divResult");
var txtUserId = document.getElementById("txtUserId");
//Build the JSON Data Object to Send to Server
var data = {};
data.user_id = txtUserId.value;
var params = new URLSearchParams(data);
//Create the Http Request
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4) {
if (this.status == 200) {
//Success. Display Result here
divResult.innerHTML = this.responseText;
}
else {
//Error. Display Error Message here
divResult.innerHTML = this.responseText;
}
}
};
xhttp.open("POST", "/api.php/get_post_count_for_user", true);
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhttp.send(params);
@mevdschee I have the entire working code... Do you want me to send a pull request? We can put it as a sample code.
@cherianmpaul that would be wonderful! You could make a examples/clients folder in which you implement a client (as I've done in the php-crud-api project).
https://github.com/mevdschee/php-crud-api/tree/master/examples/clients
I'm happy to merge any pull request, make sure you register at Hacktoberfest, see: https://hacktoberfest.digitalocean.com (you may earn a t-shirt).