doushan6161 2011-08-27 02:00
浏览 35
已采纳

Codeigniter - 显示视图文件后如何在服务器上工作?

What is the best way of spitting out the view file in codeigniter and still doing some work on the server? The situation basically is:

  1. I have a payPal checkout where user goes to paypal and clicks Pay Now! A set_express_checkout() is called to start things off.
  2. The user is returned to the Thank You page.
  3. I have to call a Get_express_checkout_details() and a do_checkout() before showing him the Thank you page and this is 2 calls to a pretty slow payPal server.

My problem is, that when the user clicks on Pay Now! button, he is redirected back to my site but hangs at payPal for at least 5 seconds (while my server makes the 2 requests) before he can se anything. So the question is: Where should I make these two calls so the user doesnt have to wait so long before anything is shown to them?

  • 写回答

2条回答 默认 最新

  • dongmu7335 2011-08-27 04:10
    关注

    I think using AJAX request is justwhat youwant. The idea is the following:

    1. Output your page to client not performing any paypal requests
    2. Create additional page/method that only performs paypal request and outputs data as json
    3. On the outputted page place AJAX call to that new page
    4. Process the response to know, if the request was successful.

    For ajax calls youmight want to have a look at jQuery.ajax. Most convenient way to output json data from PHP is using json_encode PHP function.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统