How does Node get the value that the front-end Ajax passes to the back-end through Jsonp?

the front end uses the $.ajax method of Jquery, and uses the way of jsop to obtain the value of the back end across domains. The backend is built with Node+express, and the value of the backend can be obtained normally. But if the ajax takes the parameter values, the backend will not be able to get the values passed by the front end like the following.

$.ajax({
        type: "get",
        url: "https://www.gooomi.cn/goods?search_value="+search_value,
        dataType: "jsonp",
        jsonp: "jsonpCallback",
        success:function(res){
            console.log(res)
        }
       })
    

node is obtained through res.query.search_value , and an error will be reported.
how should node get the value from jsonp correctly?


run down with your code and receive it normally. It is recommended to check the code to see if it is caused by manual miswriting of the variable name.

// app.js
const express = require('express')
const app = express()

app.get('/test', function (req, res) {
    res.send(req.query.search_value)
})

app.listen(3000, () => console.log('Example app listening on port 3000!'))
// index.js
<script>
    window.onload = function () {
        initData();
    }

    function initData() {
        $.ajax({
            type: "get",
            url: "http://localhost:3000/test?search_value=" + 555,
            dataType: "jsonp",
            jsonp: "jsonpCallback",
            success: function (res) {
                console.log(res)
            }
        })    
    }   
</script>

result:


eval / new function

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2bfff-2bae6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2bfff-2bae6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?