当我通过AJAX将POST数据传递给我的控制器时,它是空的.在AJAX中,数据仍然存在,但在我发送控制器之后,它说它是空的.
AJAX:
  function usernameCheck()
{
    var input = document.getElementById("usernameInput");
    var icon = document.getElementById("userIcon");
    var xmlhttp,
        username = document.getElementById("usernameInput"),
        message = document.getElementById("usernameMessage");
    if (username.value != "") {
        if (window.XMLHttpRequest) {
           // code for IE7+, Firefox, Chrome, Opera, Safari
           xmlhttp=new XMLHttpRequest();
        } else {
            // code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState==4 && xmlhttp.status==200) {
                // FOR DEBUGGING
                console.log(xmlhttp.responseText);
            }
        }
    }
    xmlhttp.open("POST", "usernamevalidation", true);
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttp.send("username=" + username.value);
    }
  }
Run Code Online (Sandbox Code Playgroud)
routes.php文件:
Route::post('usernamevalidation', 'UserController@validateUsername');
Run Code Online (Sandbox Code Playgroud)
UserController.php: …
我在我的项目中初始化了一个新的 firebase 项目。我向我的项目添加了函数,并且正在尝试部署默认的 helloWorld 函数。
const functions = require("firebase-functions");
// // Create and deploy your first functions
// // https://firebase.google.com/docs/functions/get-started
//
exports.helloWorld = functions.https.onRequest((request, response) => {
  functions.logger.info("Hello logs!", {structuredData: true});
  response.send("Hello from Firebase!");
});
Run Code Online (Sandbox Code Playgroud)
当我这样做时,我收到以下错误,说它缺少很多我从未听说过的软件包。
i  functions: updating Node.js 16 function helloWorld(us-central1)...
Build failed: ...c-fn@2.1.0 from lock file
npm ERR! Missing: error-ex@1.3.2 from lock file
npm ERR! Missing: json-parse-even-better-errors@2.3.1 from lock file
npm ERR! Missing: lines-and-columns@1.2.4 from lock file
npm ERR! Missing: is-arrayish@0.2.1 from lock file
npm ERR! Missing: …Run Code Online (Sandbox Code Playgroud)