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

CHAPTER 8 ■ EDITING THE CALENDAR WITH AJAX AND JQUERY event_title=Test+Event&event_start=2010-01-04+08%3A00%3A00&event_end=2010-01-04+10%3A00 %3A00&event_description=This+is+a+test+description.&event_id=&token=a52412c2e7bfb993844 0dc9d4e0867370e350134&action=event_edit Submitting the Serialized Form Data to the Processing File Now that the form data is serialized, you’re ready use $.ajax() to send the data to the processing file. Use the POST method to submit the serialized data to , and then fade out the modal window and overlay using () on a successful submission. Also, log a confirmation message in the Firebug console and append the following bold code to : // Edits events without reloading $(".edit-form input[type=submit]").live("click", function(event){ // Prevents the default form action from executing ();. | CHAPTER 8 EDITING THE CALENDAR WITH AJAX AND JQUERY event_title Test Event event_start 2O1O-O1-O4 O8 3AOO 3AOO event_end 2O1O-O1-O4 1O 3AOO Q 3AOO event_description This is a test description. event_id token a52412c2e7bfb993844 Q Odc9d4eO86737Oe35O134 action event_edit Submitting the Serialized Form Data to the Processing File Now that the form data is serialized you re ready use .ajax to send the data to the processing file. Use the POST method to submit the serialized data to and then fade out the modal window and overlay using on a successful submission. Also log a confirmation message in the Firebug console and append the following bold code to 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 Sends the data to the processing file .ajax type POST url processFile data formData success function data Fades out the modal window Logs a message to the console Event saved error function msg alert msg At this point the script is ready to save new events. First however you need to modify to accept this data. Modifying the AJAX Processing File to Handle New Submissions Getting ready to accept submissions from the event editing form is as easy as adding a new element to the lookup array 271 CHAPTER 8 EDITING THE CALENDAR WITH AJAX AND JQUERY 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 Create a lookup array for form actions actions array event_view array object Calendar method displayEvent edit_event array object Calendar method displayForm event_edit array object Calendar method processForm Make sure the anti-CSRF token was passed and that the requested action exists in the .

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
5    68    1    28-06-2024
Đã 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.