http:// problem

$form_body .= elgg_view('input/text', array('internalid' => 'url','internalname' => 'url', 'value' => $url,'class' => 'cc'));
$form_body .="<a href=\"#\" class='attach_btn cc' onclick=\"check_promotional_code('url')\">Attach</a>";

using above input box iam giving text values and with attach button iam showing that text to above the box using ajax.

but when i give a URL like "http://suryakanthi.info" into that text box ,the word not seeing above the box..(ie its not attaching..)

but when i give "www.suryakanthi.info" its will work..

when i run these code with normal html page both are working...

Iam giving "http://suryakanthi.info" in some where other in my site without ajax.. here there is no problem...

Iam using elgg1.7.11

I want to know what is the problem with http://?

  • Looks like this is your own JavaScript code (check_promotional_code()) and you need to debug that.

  • when i run these code with normal html page both are working...

  • Show the full code and we can help debug it. Otherwise we have nowhere to start from.

  •  

    THE CODE IN PHP PAGE

    <script>
    function check_promotional_code(id){
        $.ajax({
        url:"<?php echo $vars['url'];?>account/ajax.php?code="+$("#"+id).val(),
        success: function(data){
            $("#result").html(data);
             $(".cc").hide();
        }

    });
    }
    </script>

    <?php
    $url = $_SESSION['sharedly']->url;
    $title = $_SESSION['sharedly']->title;
    $description = $_SESSION['sharedly']->description;
    $tags = $_SESSION['sharedly']->tags;

    $form_body .="<label class='share_update_area-label' for='share_update_area'>Share an update</label>";
    $form_body .= elgg_view('input/text', array('internalname' => 'title', 'value' => $title, 'class' => 'share_update_area'));

    $form_body .= "<div class='link'><a href=\"#\" class='image show_hide'>Attach</a><a href=\"#\" class='show_hide'>Attach a link</a> </div>";


    $form_body .= "<div class='slidingDiv'>";
    $form_body .= elgg_view('input/text', array('internalid' => 'url','internalname' => 'url', 'value' => $url,'class' => 'cc'));
    $form_body .="<a href=\"#\" class='attach_btn cc' onclick=\"check_promotional_code('url')\">Attach</a><a href=\"#\" class='show_ss cc' style='margin-left:14px;font-weight:bold'>X</a>";
    $form_body .= "<span id='result'></span></div>";
    $form_body .= elgg_view('input/submit', array('internalname' => 'submit', 'value' => '', 'class' => 'share_btn'));
     
    echo elgg_view('input/form', array('body' => $form_body, 'action' => "{$CONFIG->url}pg/sharedly/action_add"));


    ?>

     

     

    AJAX.PHP CONTAINS

     

    <?php
    if(isset($_GET['code']))
    {
    echo $_GET['code'];
    //here u can write any db code
    }
    ?>

  • htmlawed plugin could be stripping the http:// from the text input for safety reasons. Try disabling that plugin and have another go. If it works, then you will have to find a workaround to ignore the htmlawed plugin during this action.

    Another option could be to add the http:// in the Ajax.php to the incoming "code" before sending it back out again.

  • when i give a spce between val( )

    $vars['url'];?>account/ajax.php?code="+$("#"+id).val(),

    it working with hosting domian url...

    but other url hav the same problem.