From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,NO_DNS_FOR_FROM, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from [192.168.88.254] (unknown [36.73.79.120]) by gnuweeb.org (Postfix) with ESMTPSA id E58887E595; Sun, 12 Jun 2022 12:46:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1655038003; bh=Daee1tyqWYFXWI2ruazthg5gcgBkxxd1+Oypi1/NWus=; h=Date:To:Cc:References:From:Subject:In-Reply-To:From; b=qtq5I7ec0ZAin/0jc/5nlrt7Qi8dHqP2gW8vNx7llvbT54vzF4QnLos7hRBrkdZnw 8r9+RrzF4vishIJ60UyHXQW9W6usj6ruJV/NY+Udoc98dl5VTz4Vh3EpVyF2XxqGSq zcBYWpoltDyhdbXKl48/Z9S9PZH0uNhUbnWpj23gCYvy6bwKYWT2RpsgpSVSkf9sv4 aVW1vg7zgwGHV3YqUqK61uMs9Vof6AcKM+GpXo5lBIZmSN88MEX5XKhqKa72VntH0A 3yU2MuqBP59noOL1SNtVX+W5OAjPPjmmMpx07onLAmK3mfWVpb77jUbdqRfeBupVoE qIf7zpItMPi+w== Message-ID: Date: Sun, 12 Jun 2022 19:46:30 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Content-Language: en-US To: Alviro Iskandar Setiawan , Fernanda Ma'rouf , Akiekano Cc: GNU/Weeb Mailing List , Ammar Alifian Fahdan , Irvan Malik Azantha , Khoiri , Muhammad Irvan Hakim References: <20220612120720.2750101-8-alviro.iskandar@gnuweeb.org> From: Ammar Faizi Subject: Re: [PATCH buubuu v1 08/10] view: Put the style and JS preload script to top In-Reply-To: <20220612120720.2750101-8-alviro.iskandar@gnuweeb.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: On 6/12/22 7:07 PM, Alviro Iskandar Setiawan wrote: > + let xhr = new XMLHttpRequest(); > + xhr.open("POST", "/auth/register"); > + xhr.setRequestHeader("Content-type", "application/json"); > + xhr.send(JSON.stringify(json)); What is the outcome of this code? From what I see, what you do are: 1. You create an XHR instance. 2. Open an HTTP POST to "/auth/register". 3. Set the content type to "application/json". 4. Send the stringified JSON. After that, it does nothing. How do you handle the response from the server? This definitely needs a callback to actually work. For example, setting the onload property like this can do: xhr.onload = function () { let res = this.responseText; // do whatever with res }; Or you might as well handle non-successful response with onreadystatechange like this: xhr.onreadystatechange = function () { if (this.readyState != 4) return; let res = this.responseText; // do whatever with res }; Without such a callback, this only partially works. The client side will see nothing. -- Ammar Faizi