Beginning Ajax with PHP From Novice to Professional P7

, nhưng khi bạn xây dựng dựa trên ví dụ này trong suốt chương, nó sẽ trở thành một yếu tố quan trọng hơn trong việc xây dựng một cấu trúc Ajax đầy đủ. Khi hình thức nộp, PHP tập tin sau đây (được nạp vào các khung nội tuyến) sẽ xử lý các tập tin thực tế tải lên. Xem xét các kịch bản PHP trong Ví dụ 6-2. | CHAPTER 9 WEB SERVICES 141 Listing 9-4. The SOAP Web Service Code That Returns Game Scores php Generate some fake game data. games array games array date hometeam awayteam homescore awayscore games array date hometeam awayteam homescore awayscore games array date hometeam awayteam homescore awayscore 2006-01-23 Calgary Flames Edmonton Oilers rand 1 5 rand 1 5 2006-01-23 Los Angeles Kings Anaheim Mighty Ducks rand 1 5 rand 1 5 2006-01-24 Anaheim Mighty Ducks Calgary Flames rand 1 5 rand 1 5 Return all of the games found for the given date. function getHockeyGames date ret array foreach GLOBALS games as game if date game date ret game return ret Create the SOAP server and add the getHockeyGames function to it. soap new SoapServer null array uri soap- addFunction getHockeyGames 142 CHAPTER 9 WEB SERVICES Use the request to try to invoke the service. if _SERVER REQUEST_METHOD POST soap- handle else echo Available functions n foreach soap- getFunctions as func echo func . n How the SOAP Application Works OK so you ve had a look at the code and what it looks like in its finished format now let s have a look at how the script works. The centralized page you load into your browser is . Here you will note that the loadthescores function is called when the page has completed loading. This will populate the page with the scores initially and then trigger the continual updates. We will look at how this function works shortly. Two parameters are also passed into this function. The first is the date for which the scores will be obtained and the second is the name of the div where the results will be displayed. body onload loadthescores 2006-01-23 scorescontainer div class hockeybox h2 Hockey Scores h2 -- Load the Ajax response data into here -- div id scorescontainer div div Here is the actual loadthescores function itself contained within the file . The first thing to do is update the target element to display a

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
20    67    2    21-05-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.