且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我如何将提取的Json数据导入到数据库中

更新时间:2022-11-03 08:40:37

你可以从你的api响应中创建一个json对象

You can create a json object from your api response(in same function where you are creating html).

 JSONData = JSON.stringify({
            "Title": Title,
            "Year": Year,
            "Rated" : Rated,
            ...........so on

        });
postDataToserver(JSONData);

你可以定义你的函数来发布数据,比如 -

And you can define your function to post data like -

function postDataToserver(JSONData)
    $.ajax({
        url: "your_server_script_path",
        type:"POST",
        data:JSONData,
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function(response) {
        error: function (error) {

        }
    });

如果您想以简单的发布格式发送而不是JSON对象,那么您不需要使用JSON.stringify和类似的功能删除contentype信息。希望这会帮助你。

If you want to send in simple post format not as JSON object then you don't need to use JSON.stringify and similarly in function remove contentype information. Hope this will help you.