Tương tác giữa PHP và jQuery - part 31

CHAPTER 8 ■ EDITING THE CALENDAR WITH AJAX AND JQUERY Configuring the Form Submission Event Handler for Deletion Confirming event deletion requires a little more modification to . To execute properly, the value of the Submit button needs to be stored and passed to the processing file. This is because the form can be submitted with either Yes, Delete It or Nope! Just Kidding! as values; the script checks which button was clicked to determine what action to take. To store the button’s value, use the this keyword as the jQuery selector, and then store the returned string from .val() as a. | CHAPTER 8 EDITING THE CALENDAR WITH AJAX AND JQUERY Configuring the Form Submission Event Handler for Deletion Confirming event deletion requires a little more modification to . To execute properly the value of the Submit button needs to be stored and passed to the processing file. This is because the form can be submitted with either Yes Delete It or Nope Just Kidding as values the script checks which button was clicked to determine what action to take. To store the button s value use the this keyword as the jQuery selector and then store the returned string from .val as a variable called submitVal. Next check whether the button s name attribute is confirm_delete. If so append the action confirm_delete and the value of the button to the query string before submitting it. Insert the following code shown in bold to accomplish this Edits events without reloading .edit-form input type submit .live click function event Prevents the default form action from executing Serializes the form data for use with .ajax var formData this .parents form .serialize Stores the value of the submit button submitVal this .val If this is the deletion form appends an action if this .attr name confirm delete Adds necessary info to the query string formData action confirm_delete confirm delete submitVal Sends the data to the processing file .ajax type POST url processFile data formData success function data Fades out the modal window If this is a new event adds it to the calendar if name event_id .val .length 0 data formData error function msg alert msg 301 CHAPTER 8 EDITING THE CALENDAR WITH AJAX AND JQUERY Modifying the Processing File to Confirm Deletion Finally you need to add an additional element to the lookup array in to make the Delete button work php Enable sessions session_start Include necessary files include_once . . . sys config Define constants for config info foreach C as name val define name val .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.