Dies ist eine alte Version des Dokuments!


A PCRE internal error occured. This might be caused by a faulty plugin

====== JSONP mit jQuery und PHP ====== <code javascript> $.ajax({ url:'[url]', dataType: 'jsonp', jsonp: 'jsonp_callback', type: 'get', data: $('form').serialize(), success: function( json ){ if( json == null ) { alert('Keine Ergebnisse') } var jLen = json.length; html = ''; for( var i = 0; i < jLen; i++ ){ html += '<label>'; html += '<input type="checkbox" name="' + _select+'" value="'+json[i][fields[0]]+'" />' + json[ i ][ fields[1] ]; html += '</label>' } _target.html( html ); }, error: function(e){alert(e)} }); </code> <code php> <?php require_once( 'MDB2.php' ); require_once( 'MDB2/Driver/mysqli.php' ); include( 'includes/config.db.inc.php' ); // db config include( 'includes/functions.db.inc.php' ); // db connection management $query = $_POST['query']; // read query from post if( $_POST['query'] == "" ) { $query = $_GET['query']; // read query from get } // connect DB dbConnect(); //get Result Object $xResObj = dbPutQuery($query); // set header to put JSON Content //header( 'Content-Type: text/json' ); // convert result object to json and print $data = json_encode( $xResObj ); if( $_GET['jsonp_callback'] ) { echo $_GET['jsonp_callback'] . '(' . $data . ');'; } else { echo $data; } </code>

Navigation

Impressum

Drucken/exportieren
In anderen Sprachen
Übersetzungen dieser Seite: