How does easymock judge?

problem description

there is no way to dynamically change the value of success in the returned data

the environmental background of the problems and what methods you have tried

I use ajax as a login interface. Because there is no background, I use easymock to write fake data, but I find that the success in the data returned by ajax is always a fixed value. Cannot change dynamically as in php

< H1 > html Code < / H1 >
<div id="wrapper">
    <h1 id="title"></h1>
    <div id="content">
        <label for="username"></label>
        <input type="text" id="username" value>
        <br/>
        <label for="pass"></label>
        <input type="password" id="pass" value>
    </div>
    <div id="btn">
        <button id="login"></button>
        <a href="-sharp"></a>
    </div>
</div>
< H1 > js Code: < / H1 >

var username=document.getElementById ("username"). Value;
var pass=document.getElementById ("pass"). Value;
var btn=document.getElementById ("login");
var xhr;
btn.onclick=function () {

if(window.XMLHttpRequest){
    xhr=new XMLHttpRequest();
}
else{
    xhr=new ActiveXObject("Microsoft.XMLHttpRequest");
}
xhr.open("get","https://easy-mock.com/mock/5b57d2a603a5844b1c942098/user/query?name="+username+"&pass="+pass,true);
xhr.send();
xhr.onreadystatechange=function () {
    if(xhr.readyState==4){
        if(xhr.status==200){
            console.log("");
            var data=JSON.parse(xhr.responseText);
            console.log(data);
            if(data.success){
                window.location.href="indexJS.html"
            }
            else{
                alert("");
            }
        }
    }
}

}

easymock data

what result do you expect? What is the error message actually seen?

I want to be able to determine whether the filled data exists in the simulation data, and if so, let the success in the returned data be true

.
Mar.30,2021
The

problem has been resolved.
uses the _ req object, gets the parameter value through the _ req.query property, determines whether it is equal to one of the values, and returns true if so. If not, return false

Menu