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