Use correct Content-Type header for JSON output

This commit is contained in:
Geert De Deckere 2013-01-16 16:00:11 +01:00
parent 44013d4480
commit 5da944af3c
1 changed files with 17 additions and 3 deletions

View File

@ -24,6 +24,8 @@ function woocommerce_sidebar_login_ajax_process() {
check_ajax_referer( 'woocommerce-sidebar-login-action', 'security' );
header( 'Content-Type: application/json; charset=utf-8' );
// Get post data
$creds = array();
$creds['user_login'] = $_REQUEST['user_login'];
@ -73,8 +75,6 @@ function woocommerce_sidebar_login_ajax_process() {
}
}
header( 'content-type: application/json; charset=utf-8' );
echo esc_js( $_GET['callback'] ) . '(' . json_encode( $result ) . ')';
die();
@ -219,6 +219,8 @@ function woocommerce_ajax_add_to_cart() {
check_ajax_referer( 'add-to-cart', 'security' );
header( 'Content-Type: application/json; charset=utf-8' );
$product_id = (int) apply_filters('woocommerce_add_to_cart_product_id', $_POST['product_id']);
$passed_validation = apply_filters('woocommerce_add_to_cart_validation', true, $product_id, 1);
@ -360,6 +362,8 @@ function woocommerce_add_new_attribute() {
check_ajax_referer( 'add-attribute', 'security' );
header( 'Content-Type: application/json; charset=utf-8' );
$taxonomy = esc_attr( $_POST['taxonomy'] );
$term = stripslashes( $_POST['term'] );
@ -914,6 +918,8 @@ function woocommerce_get_customer_details() {
check_ajax_referer( 'get-customer-details', 'security' );
header( 'Content-Type: application/json; charset=utf-8' );
$user_id = (int) trim(stripslashes($_POST['user_id']));
$type_to_load = esc_attr(trim(stripslashes($_POST['type_to_load'])));
@ -931,7 +937,7 @@ function woocommerce_get_customer_details() {
$type_to_load . '_phone' => get_user_meta( $user_id, $type_to_load . '_phone', true ),
);
echo json_encode($customer_data);
echo json_encode( $customer_data );
// Quit out
die();
@ -1223,6 +1229,8 @@ function woocommerce_calc_line_taxes() {
check_ajax_referer( 'calc-totals', 'security' );
header( 'Content-Type: application/json; charset=utf-8' );
$tax = new WC_Tax();
$taxes = $tax_rows = $item_taxes = $shipping_taxes = array();
@ -1538,6 +1546,8 @@ function woocommerce_json_search_products( $x = '', $post_types = array('product
check_ajax_referer( 'search-products', 'security' );
header( 'Content-Type: application/json; charset=utf-8' );
$term = (string) urldecode(stripslashes(strip_tags($_GET['term'])));
if (empty($term)) die();
@ -1649,6 +1659,8 @@ function woocommerce_json_search_customers() {
check_ajax_referer( 'search-customers', 'security' );
header( 'Content-Type: application/json; charset=utf-8' );
$term = urldecode( stripslashes( strip_tags( $_GET['term'] ) ) );
if ( empty( $term ) )
@ -1785,6 +1797,8 @@ function woocommerce_product_ordering() {
if ( ! $post = get_post( $_POST['id'] ) )
die(-1);
header( 'Content-Type: application/json; charset=utf-8' );
$previd = isset( $_POST['previd'] ) ? $_POST['previd'] : false;
$nextid = isset( $_POST['nextid'] ) ? $_POST['nextid'] : false;
$new_pos = array(); // store new positions for ajax