+ 2
Anyone use XAMPP and can assist me with this please?
I want to look up any Superhero by their name or alias and retrieve only that superhero or leave the text field blank and when I click search, it should return the original list of superheroes: Captain America Ironman Captain Marvel etc⊠I added the PHP code for it. However, when I click search itâs showing everything in the PHP file, even the closing tags. Iâd really appreciate the help. https://code.sololearn.com/WGKTeL1GY69H/?ref=app
15 Answers
+ 5
// This works for me:
onload = () => {
var Btn = document.getElementById('searchBtn');
var result = document.getElementById('result');
var heroName= document.getElementById('searchBox');
Btn.onclick = event => {
fetch(`superheroes.php?query=${heroName.value}`, {
method: 'GET'})
//fetch(`superheroes.php?query=${heroName.value}`)
.then(response =>{
return response.text(); // return the response as text
})
.then(data =>{
result.innerHTML= data;
});
}
}
+ 4
JaScript thank you. Did you modify the php code; Are you able to search for each character by name? When I click on search, I'm getting:
, "name" => "Steve Rogers", "alias" => "Captain America", "biography" => "Recipient of the Super-Soldier serum, World War II hero Steve Rogers fights for American ideals as one of the worldâs mightiest heroes and the leader of the Avengers.", ], [ "id" => 2, "name" => "Tony Stark", "alias" => "Ironman",
And not a list with their Alias.
+ 2
For a super hero that is found, the result should look like this:
IRON MAN
AKA TONY STARK
Genius. Billionaire. PlayboyâŠ
+ 2
To fix it you can cut the first loop and put them into last if statement.
+ 2
Triz how it works you can see here:
https://dl.dropbox.com/s/7neg4mu3xkj8n7o/avengers.mov?raw=1
+ 2
Triz An idea will be to remove the apostrophe from the user searching input and from php searching algorithm.
+ 1
I checked again the php isnât changed only app.js. Here a picture of a searching result:
https://dl.dropbox.com/s/432pk0smh9dq836/Bildschirmfoto%202022-11-06%20um%2022.35.22.png?raw=1
+ 1
JaScript when you search for a specific character, the list with the other superheroes shouldnât be showing but I donât know how to fix that as yet
+ 1
Triz For small tasks and training I use DraftCode on iPad. This app uses XAMPP implementation for server features and MySql for database.
+ 1
JaScript I got it to work. Thanks alot!!! I really really appreciate it!
+ 1
JaScript Ok. Thanks again!
+ 1
JaScript When i search for Tâchalla, it says user not fount but itâs in the array. I think itâs because of the apostrophe, any idea how to fix this?
+ 1
Triz did you fix the apostrophe problem?
0
Very nice.
0
Hello.