I been trying to post json values to an API, with the code bellow. Maybe I should use another approach to send/post json values to an API. Couls somebody give me a hint? I wanna be able to post a new username and password to the API (username=bruno&password=login), how is it possible to do that? Can I do It only using javascript?
var url = "http://192.168.8.143/api/v11/login/";
var parameters = "username=bruno&password=login";
http.open("POST", url, true);
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", parameters .length);
http.setRequestHeader("Connection", "close");
http.onreadystatechange = function() {//Handler function for call back on state change.
if(http.readyState == 4) {
alert(http.responseText);
}
}
http.send(parameters);
Parse error: syntax error, unexpected '=' in /var/www/html/api/v11/Json.php(34) : eval()'d code on line 1
Warning: Invalid argument supplied for foreach() in /var/www/html/api/v11/Json.php on line 6
– Mr Toni WP Mar 03 '14 at 15:27