0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AJAX に基づくログインページ01ー AJAXの簡単な使い方

Last updated at Posted at 2024-10-21
const username = "randomuser"
const password = "123456"
const p_element = document.querySelector('.my_p_1')

axios({
    url: 'http://hmajax.itheima.net/api/login',
    method:'POST',
    data:{
        username,
        password
    }
}).then(result => {
    console.log(result.data.message)
    if(p_element){
        p_element.innerHTML = result.data.message
    }
}).catch(error=>{
    console.log(error.response.data.message)
    if(p_element){
        p_element.innerHTML = error.response.data.message
    }
}) 


0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?