Title: Json+ld
Last modified: August 18, 2019

---

# Json+ld

 *  [mfercho7](https://wordpress.org/support/users/mfercho7/)
 * (@mfercho7)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/jsonld/)
 * I am creating a plugins where I use several select in the plugin administration
   panel, I have a function that shows the select and I use an ajax script where
   I pass values to a B file where I receive the values and with functions I build
   the json, but in the point where they receive the values arrive empty.
 * B file:
 * //We get the input data
    $select_1 = $_GET[“select_1”]; $select_2 = $_GET[“select_2”];
   $select_3 = $_GET[“select_3”]; echo $select_1; echo $select_2;//I verify that
   the data arrives well echo $select_3; function theme_head_script($select_1,$select_2,
   $select_3){ // We make the necessary checks … (sanitize the texts to avoid XSS
   and code injections, check that the age is a number, etc.) // Omitted for code
   brevity // BUT DON’T FORGET THAT IT IS SOMETHING IMPORTANT. // Set the “content-
   type” header as “JSON” so that jQuery recognizes it as such
 * header(‘Content-Type: application/json’);
    // We save the data in an array $datos
   = array(
 * ‘@context’=> ‘[http://schema.org&#8217](http://schema.org&#8217);,
    ‘@type’=>‘
   CollegeOrUniversity’, ‘sameAs’ => $select_1, ‘address’ => [ ‘@type’=> ‘PostalAddress’,‘
   streetAddress’=> $select_2, ‘addressLocality’=> $select_3, ‘addressRegion’=> ‘
   Estado Carabobo’, ‘postalCode’=> ‘2005’, ‘addressCountry’=> ‘VE’ ]
 * );
    // We return the array passed to JSON as an object
 * echo json_encode($datos, JSON_FORCE_OBJECT);
    // Always die in functions echoing
   ajax content
 * }
 * add_action( ‘wp_head’, ‘theme_head_script’ );
    //Also in the function of add_action
   does not recognize it as one within the context of wordpress.
 * //Do you have any idea how you can help me .. thanks

The topic ‘Json+ld’ is closed to new replies.

## Tags

 * [json](https://wordpress.org/support/topic-tag/json/)
 * [jsonld](https://wordpress.org/support/topic-tag/jsonld/)

 * 0 replies
 * 1 participant
 * Last reply from: [mfercho7](https://wordpress.org/support/users/mfercho7/)
 * Last activity: [6 years, 9 months ago](https://wordpress.org/support/topic/jsonld/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
