Opened 11 years ago

Closed 10 years ago

#555 closed new feature (fixed)

ajax and json support in our framework

Reported by: lemon-head Owned by: lemon-head
Priority: major Milestone: Rox Framework, Upgrade
Component: FrameWork Keywords: json, ajax, xml
Cc:

Description

This will be a cool thing for our ajaxchat, or eventually for searchmembers or signup location picker.

See the #116 ajaxchat application for how to use.

JSON

  • ajax request string must be '.../json/ajaxchat/...' (for ajaxchat application)
  • framework will call !AjaxchatController::json($args, $json_object), where
    • $json_object is a stdClass object, waiting to be filled with values.
    • $args provides you with $args->request, $args->post, $args->get.
    • all text output (echo) is buffered, so it does not break the json notation.
  • the contents of the $json_object will be given to the javascript prototype callback in json object notation.
    • in the prototype callback function "my_callback_func(transport)", you get the object by "transport.responseJSON".
    • "transport.responseJSON.text" is the buffered text. You can display it somewhere in a div box, in an alert, or what you like.
    • "transport.responseJSON.alerts" is an array of alert texts. You are supposed to fire these alerts to the user..
    • you can define other attributes in the json object, as you prefer.

XML

  • not yet implemented..
  • ajax request string would be '.../xml/searchmembers/...' (for instance)
  • framework would call !SearchmembersController::xml($args)
  • in some way the framework will make sure that the output is valid xml, and that whatever error messages will not break that.

Change History (4)

comment:1 Changed 11 years ago by lemon-head

  • follow_up changed from none to test
  • Owner set to lemon-head
  • Status changed from new to assigned

How to test? Try the ajax chat, #116.

comment:2 Changed 10 years ago by lemon-head

What is the best way to tell the framework we want json format?

  • bewelcome.org/json/ajaxchat/whatever
  • bewelcome.org/ajaxchat/json/whatever
  • bewelcome.org/ajaxchat/whatever.json
  • bewelcome.org/ajaxchat.json/whatever
  • bewelcome.org/.json/ajaxchat/whatever

comment:3 Changed 10 years ago by guaka

ajaxchat is live now

comment:4 Changed 10 years ago by philipp

  • follow_up changed from test to none
  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.