What should I do if I want to put the dictionary value of json format in another Ajax as a form data factor?

Asked 2 years ago, Updated 2 years ago, 47 views

I tried to get a new value by transferring one of the json.dumps values to form data by using ajax once more in ajax (inside the success) such as json.dumps, but it says I can't find it. When I took an alt using JSON.parse, it was output only as an object, and when ajax turned, the definition popped up the same way

If the value of the first success is passed to the unique_key value string instead of the transformed value of the dictionary type json.dumps, the code below will function normally.

Below is the example code. When I took a photo of the alot in the first success,

{"msg": "\uac80\uc0c9\uc911\uc785\ub2c8\ub2e4.", "unique_key": 1583979316}

The result comes out and all I need is the unique_key's Velu, 1583979316, so how can I take out the Velu only and use it?

 success: function(data) {
            alert(data);
            let test2 = data[unique_key];
            let form_data = {_unique_key: test2}
            if (test2 != null){
            $.ajax({
                type: 'post',
                url: "Example code empty",
                dataType: "text",
                timeout: 1000,
                data: form_data,
                error: function(request, status, error){
                    alert ("Fail");
                    console.log(request, status, error);
                },
                success: function(data) {
                    console.log(data)
                }
            });}

ajax javascript

2022-09-21 11:51

1 Answers

I'm not sure if you're asking this, but do you know? Whether to catch a mouse with the back foot of a cow 😆

JSON.parse(
    '{"msg": "\uac80\uc0c9\uc911\uc785\ub2c8\ub2e4.", "unique_key": 1583979316}'
).unique_key; // 1583979316


2022-09-21 11:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.