Sending & processing an AJAX request
This commit is contained in:
		@ -177,14 +177,13 @@
 | 
			
		||||
                        title = "",
 | 
			
		||||
                    } = c;
 | 
			
		||||
 | 
			
		||||
                    const {value: formValues} = await Swal.fire({
 | 
			
		||||
                    const {value: result} = await Swal.fire({
 | 
			
		||||
                        title: title,
 | 
			
		||||
                        html: msg,
 | 
			
		||||
                        backdrop: false,
 | 
			
		||||
                        focusConfirm: false,
 | 
			
		||||
                        showCancelButton: true,
 | 
			
		||||
                        willOpen: () => {
 | 
			
		||||
                            console.log("test")
 | 
			
		||||
                            const elem = document.getElementById('reservation-dates-modal')
 | 
			
		||||
                            const rp = new DateRangePicker(elem, {
 | 
			
		||||
                                "format": "yyyy-mm-dd",
 | 
			
		||||
@ -205,8 +204,14 @@
 | 
			
		||||
                        },
 | 
			
		||||
                    })
 | 
			
		||||
 | 
			
		||||
                    if (formValues) {
 | 
			
		||||
                        Swal.fire(JSON.stringify(formValues))
 | 
			
		||||
                    if (c.callback !== undefined) {
 | 
			
		||||
                        if (result &&
 | 
			
		||||
                            result.dismiss !== Swal.DismissReason.cancel &&
 | 
			
		||||
                            result !== "") {
 | 
			
		||||
                            c.callback(result);
 | 
			
		||||
                        } else {
 | 
			
		||||
                            c.callback(false);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -43,7 +43,20 @@
 | 
			
		||||
                    </div>
 | 
			
		||||
                </form>
 | 
			
		||||
            `;
 | 
			
		||||
        Prompt().custom({title: "Choose your dates", msg: html})
 | 
			
		||||
        Prompt().custom({
 | 
			
		||||
            title: "Choose your dates",
 | 
			
		||||
            msg: html,
 | 
			
		||||
            callback: (result) => {
 | 
			
		||||
                console.log(result);
 | 
			
		||||
 | 
			
		||||
                fetch('/availability-json')
 | 
			
		||||
                    .then(response => response.json())
 | 
			
		||||
                    .then(data => {
 | 
			
		||||
                        console.log(data);
 | 
			
		||||
                    })
 | 
			
		||||
            },
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
</script>
 | 
			
		||||
{{end}}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user