Skip to content Skip to sidebar Skip to footer

How Do I Import The Extracted Json Data To Database

I am trying to fetch movie information from omdbapi.So far i have this code which is extracting data from imdb using omdb api.But i want import that data to my database.how do i a

Solution 1:

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 -

functionpostDataToserver(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) {

        }
    });

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.

Post a Comment for "How Do I Import The Extracted Json Data To Database"