Skip to main content
added 1 characters in body
Source Link
onetrickpony
  • 13.6k
  • 7
  • 58
  • 87

I'm guessing it's because you didn't escape the single quotes. Try using output buffering, the code is more readable:

function appPrice($atts) 
{
    $atts = extract(shortcode_atts(
        array(
            'id' => '',
            'class' => '',
            'container' => ''
    ), $atts));
    ob_start();
    ?>

    <script type="text/javascript">
    $(document).ready(function() {
        var url = 'iLookup.php';

            query = <?php echo $id; ?>;

            $.getJSON(url, {id:query}, function(json) {
            $('#results').html('Price: '+json.results[0].price+'<br/>');
            });

    });
</script>

    <?php
    return ob_get_clean();
}

also the way you're loading jquery is weird. why not:

 wp_deregister_script('jquery');
 wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"), false, '1.5.0');
 wp_enqueue_script('jquery');

?

I'm guessing it's because you didn't escape the single quotes. Try using output buffering, the code is more readable:

function appPrice($atts) 
{
    $atts = shortcode_atts(
        array(
            'id' => '',
            'class' => '',
            'container' => ''
    ), $atts);
    ob_start();
    ?>

    <script type="text/javascript">
    $(document).ready(function() {
        var url = 'iLookup.php';

            query = <?php echo $id; ?>;

            $.getJSON(url, {id:query}, function(json) {
            $('#results').html('Price: '+json.results[0].price+'<br/>');
            });

    });
</script>

    <?php
    return ob_get_clean();
}

also the way you're loading jquery is weird. why not:

 wp_deregister_script('jquery');
 wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"), false, '1.5.0');
 wp_enqueue_script('jquery');

?

I'm guessing it's because you didn't escape the single quotes. Try using output buffering, the code is more readable:

function appPrice($atts) 
{
    extract(shortcode_atts(
        array(
            'id' => '',
            'class' => '',
            'container' => ''
    ), $atts));
    ob_start();
    ?>

    <script type="text/javascript">
    $(document).ready(function() {
        var url = 'iLookup.php';

            query = <?php echo $id; ?>;

            $.getJSON(url, {id:query}, function(json) {
            $('#results').html('Price: '+json.results[0].price+'<br/>');
            });

    });
</script>

    <?php
    return ob_get_clean();
}

also the way you're loading jquery is weird. why not:

 wp_deregister_script('jquery');
 wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"), false, '1.5.0');
 wp_enqueue_script('jquery');

?

added 15 characters in body
Source Link
onetrickpony
  • 13.6k
  • 7
  • 58
  • 87

I'm guessing it's because you didn't escape the single quotes. Try using output buffering, the code is more readable:

function appPrice($atts) 
{
    $atts = shortcode_atts(
        array(
            'id' => '',
            'class' => '',
            'container' => ''
    ), $atts);
    ob_start();
    ?>

    <script type="text/javascript">
    $(document).ready(function() {
        var url = 'iLookup.php';

            query = <?php echo $id; ?>;

            $.getJSON(url, {id:query}, function(json) {
            $('#results').html('Price: '+json.results[0].price+'<br/>');
            });

    });
</script>

    <?php
    return ob_get_clean();
}

also the way you're loading jquery is weird. why not:

 wp_deregister_script('jquery');
 wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"), false, '1.5.0');
 wp_enqueue_script('jquery');

?

I'm guessing it's because you didn't escape the single quotes. Try using output buffering, the code is more readable:

function appPrice($atts) 
{
    $atts = shortcode_atts(
        array(
            'id' => '',
            'class' => '',
            'container' => ''
    ), $atts);
    ob_start();
    ?>

    <script type="text/javascript">
    $(document).ready(function() {
        var url = 'iLookup.php';

            query = $id;

            $.getJSON(url, {id:query}, function(json) {
            $('#results').html('Price: '+json.results[0].price+'<br/>');
            });

    });
</script>

    <?php
    return ob_get_clean();
}

also the way you're loading jquery is weird. why not:

 wp_deregister_script('jquery');
 wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"), false, '1.5.0');
 wp_enqueue_script('jquery');

?

I'm guessing it's because you didn't escape the single quotes. Try using output buffering, the code is more readable:

function appPrice($atts) 
{
    $atts = shortcode_atts(
        array(
            'id' => '',
            'class' => '',
            'container' => ''
    ), $atts);
    ob_start();
    ?>

    <script type="text/javascript">
    $(document).ready(function() {
        var url = 'iLookup.php';

            query = <?php echo $id; ?>;

            $.getJSON(url, {id:query}, function(json) {
            $('#results').html('Price: '+json.results[0].price+'<br/>');
            });

    });
</script>

    <?php
    return ob_get_clean();
}

also the way you're loading jquery is weird. why not:

 wp_deregister_script('jquery');
 wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"), false, '1.5.0');
 wp_enqueue_script('jquery');

?

Source Link
onetrickpony
  • 13.6k
  • 7
  • 58
  • 87

I'm guessing it's because you didn't escape the single quotes. Try using output buffering, the code is more readable:

function appPrice($atts) 
{
    $atts = shortcode_atts(
        array(
            'id' => '',
            'class' => '',
            'container' => ''
    ), $atts);
    ob_start();
    ?>

    <script type="text/javascript">
    $(document).ready(function() {
        var url = 'iLookup.php';

            query = $id;

            $.getJSON(url, {id:query}, function(json) {
            $('#results').html('Price: '+json.results[0].price+'<br/>');
            });

    });
</script>

    <?php
    return ob_get_clean();
}

also the way you're loading jquery is weird. why not:

 wp_deregister_script('jquery');
 wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"), false, '1.5.0');
 wp_enqueue_script('jquery');

?