Maybe i am wrong but i can not find anyone who wants to display a json message just in json format from url on the page except for me.
I have a webshop in html, javascript and css. I am looking for some code example to display the json message just on the page. I don't want to parse the json into html or what else. I just want to display the json message as it is like this format: {"success":0,"message":"User not known"}
.
This message above is the url response from my php database in xampp.
Below is my code and it works good, the problem is that this code is static. I am looking for some dynamic solution where you enter the url and it responds with json message. Any help is appriciated.
this is my login.html
if(form.id.value == "" || form.pass.value == "") {
alert("Empty details!");
}else if (form.id.value=="johan" && form.pass.value=="123") {
location="Page2.html"
} else { alert("Wrong username or password!")
}
}
and this is the json read:
// 1 - read josn:
var my_json_output = {"success":1,"message":"Vol","Username":"jan","UserSurname":"janman"}',
json_yes.succes json_yes = JSON.parse(my_json_output);
var my_json_output = '{"success":0,"message":"User_Unknown"}',
json_no = JSON.parse(my_json_output);
if(json_no.success == 1) { alert("Welcome, " + s + json_yes.Username);
}else if(json_no.success == 0) { alert("Try again");
}