jquery - Sending XML Data to MySQL database -


i trying send xml object database. have post data form turned xml object wanting send database in way allow form have additional inputs created , can later call , use xml object populate form in case users want edit form. how can send data in such way? , appreciated! gfrobenius have creating xml object:

jquery:

//grab post info, turn valid xml object , store $postdata = null; if($_server['request_method'] == 'post' && count($_post) > 0) $postdata = assocarraytoxml('post_data',$_post); //the assocarraytoxml returns xml object page breaks, need stright non-breaking string //so flexigrid can display results properly. $postdata = str_replace(chr(13), '', $postdata); $postdata = str_replace(chr(10), '', $postdata); 

function:

 function assocarraytoxml($root_element_name,$ar)     {       $xml = new simplexmlelement("<?xml version=\"1.0\"?><{$root_element_name}></{$root_element_name}>");       $f = create_function('$f,$c,$a','               foreach($a $k=>$v) {                   if(is_array($v)) {                       $ch=$c->addchild(htmlspecialchars($k));                       $f($f,$ch,$v);                   } else {                       $c->addchild($k,htmlspecialchars($v));                   }               }');       $f($f,$xml,$ar);       return $xml->asxml();     } 

i'm not sure xml object is, how i'd pass xml database.

i'd use ajax (jquery or pure js) pass client server code (webmethod in page or web service) hooks database pass xml string parameter stored procedure or parameterized sql.

should 20-30 lines of code , there million places can find examples on web on how this.

edit:

jquery example: http://api.jquery.com/jquery.ajax/

javascript example: https://developer.mozilla.org/en-us/docs/ajax/getting_started


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -