Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php o你真的认为我必须从头开始使用上面的代码吗?很高兴你能让它工作起来,在现实世界中,与我的示例相反,你会用锚定标记或其他东西的文本替换“casa”一词。例如,$(“建议a”).text()而不是ajax中的静态值“casa”。如果您误解了,很抱歉,但我没有让_Php_Javascript_Html_Parsing_Html Parsing - Fatal编程技术网

Php o你真的认为我必须从头开始使用上面的代码吗?很高兴你能让它工作起来,在现实世界中,与我的示例相反,你会用锚定标记或其他东西的文本替换“casa”一词。例如,$(“建议a”).text()而不是ajax中的静态值“casa”。如果您误解了,很抱歉,但我没有让

Php o你真的认为我必须从头开始使用上面的代码吗?很高兴你能让它工作起来,在现实世界中,与我的示例相反,你会用锚定标记或其他东西的文本替换“casa”一词。例如,$(“建议a”).text()而不是ajax中的静态值“casa”。如果您误解了,很抱歉,但我没有让,php,javascript,html,parsing,html-parsing,Php,Javascript,Html,Parsing,Html Parsing,o你真的认为我必须从头开始使用上面的代码吗?很高兴你能让它工作起来,在现实世界中,与我的示例相反,你会用锚定标记或其他东西的文本替换“casa”一词。例如,$(“建议a”).text()而不是ajax中的静态值“casa”。如果您误解了,很抱歉,但我没有让它工作。我相信在我的代码中有一些东西需要添加,而不是像你在上面所贴的那样用另一种方式来解决这个问题。下面是我要说的,点击casa: $words = array('word0','word-1'); function url_decod


o你真的认为我必须从头开始使用上面的代码吗?很高兴你能让它工作起来,在现实世界中,与我的示例相反,你会用锚定标记或其他东西的文本替换“casa”一词。例如,$(“建议a”).text()而不是ajax中的静态值“casa”。如果您误解了,很抱歉,但我没有让它工作。我相信在我的代码中有一些东西需要添加,而不是像你在上面所贴的那样用另一种方式来解决这个问题。下面是我要说的,点击casa:
$words = array('word0','word-1');
    function url_decode($string){
    return urldecode(utf8_decode($string));
    }

    $baseUrl = 'http://lema.rae.es/drae/srv/search?val=';

    $cssReplace = <<<EOT

    <style type="text/css">
    // I changed the style
    </style>
    </head>
 EOT;

 $resultIndex = 0;

foreach($words as $word) {
if(!isset($_REQUEST[$word]))
    continue;

$contents = file_get_contents($baseUrl . urldecode(utf8_decode($_REQUEST[$word])));

$contents = str_replace('</head>', $cssReplace, $contents);
$contents = preg_replace('/(search?[\d\w]+)/','http://lema.rae.es/drae/srv/search', $contents);


echo "<div style='
      //style
     ", (++$resultIndex) ,"'>", $contents,
        "</div>";
} 
<div id="wrapper">
    <!-- This output div will contain the output of whatever the MAIN
         word being displayed is, this is where HOLA would be from your first example -->
    <div id="output">

    </div>

    <!-- This is your suggestions box, assuming all anchor tags in here will result in
         a new word being displayed in output -->
    <div id="suggestions">

    </div>
</div>

<!-- Le javascript -->
<script>
    // Standard jQuery stuff, read about it on the jquery documentation
    $(function() {
        // The below line is a selector, it will select any anchor tag inside the div with 'suggestions' as identifier
        $('#suggestions a').click(function(e) {
            // First, stop the link going anywhere
            e.preventDefault();

            // Secondly, we want to replace the content from output with new content, we will use AJAX here
            // which you should also read about, basically we set a php page, and send a request to it
            // and display the result without refreshing your page
            $.ajax({
                url: 'phppage.php',
                data: { word: 'casar' },
                success: function(output) {
                    // This code here will replace the contents of the output div with the output we brought back from your php page
                    $('#output').html(output);
                }
            })
        });
    })
</script>
<?php

    $word = $_GET['word'];
    // Connect to some database, get the definitions, and store the results
    $result = someDatabaseFunctionThatDoesSomething($word);
    echo $result;
?>