1

I want to pass the variable by URL: http://localhost/new_wiki/test.php?id=http://example.com

I'm using var first = getUrlVars()["id"]; This line is the passing the value but not working please help me.

And the test.php is like this:

<!DOCTYPE html>
<html>
<head>

<link rel="stylesheet" href="css/style.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.js"></script> 
</head>
<body>

<div id="article"></div>


<script type="text/javascript">


    $(document).ready(function hiren(){

var first = getUrlVars()["id"];


    $.ajax({
        type: "GET",
        url: "first",
        contentType: "application/json; charset=utf-8",
        async: false,
        dataType: "json",
        success: function (data, textStatus, jqXHR) {

        var markup = data.parse.text["*"];
        var i = $('<div></div>').html(markup);

        // remove links as they will not work
        i.find('a').each(function() { $(this).replaceWith($(this).html()); });

        // remove any references
        i.find('sup').remove();

        // remove cite error
        i.find('.mw-ext-cite-error').remove();

        $('#article').html($(i).find('p'));



        },
        error: function (errorMessage) {
        }
    });    

    });




</script>
<h1>
</h1>




</body>
</html>

but the nothing happens what is the error in it plz help me.

sao
  • 1,835
  • 6
  • 21
  • 40

1 Answers1

0

The JS:

   $(document).ready(function hiren(){
        // On form's submit...
        $('form').submit(function(){
            // Get input's url
            var url = $('input[name="url"]').val();

            // Do ajax's GET request
            $.ajax({
                type: "GET",
                url: url, // <-- this is the url from the input
                contentType: "application/json; charset=utf-8",
                async: false,
                dataType: "json",
                success: function (data, textStatus, jqXHR) {

                    var markup = data.parse.text["*"];
                    var i = $('<div></div>').html(markup);

                    // remove links as they will not work
                    i.find('a').each(function() { $(this).replaceWith($(this).html()); });

                    // remove any references
                    i.find('sup').remove();

                    // remove cite error
                    i.find('.mw-ext-cite-error').remove();

                    $('#article').html($(i).find('p'));



                },
                error: function (errorMessage) {
                }
            });
        });
    });
Fest7
  • 306
  • 2
  • 6