marlenepune
New Member
When sending the request from the jQuery Mobile script to the specified PHP file, nothing is returned, nothing is appended to the html file. Here's the URL of the page:localhost/basket/newstext.html?url=http://www.basket-planet.com/ru/news/9235 newstext.html: \[code\]<head><script src="http://stackoverflow.com/questions/15822387/js/newstext.js"></script> </head><body> <div data-role="page" id="newstext"> <div data-role="content"> <div id="textcontent"></div> </div> </div> </body> \[/code\]newstext.js: \[code\]var serviceURL = "http://localhost/basket/services/"; $('#newstext').bind('pageshow', function(event) { var url = getUrlVars()["url"]; $.getJSON(serviceURL + 'getnewstext.php?url='+url, displayNewsText); }); function displayNewsText(data){ var newstext = data.item; $('#textcontent').text(newstext); $('#textcontent').trigger('create'); } function getUrlVars(){ //it displays in the alert perfectly, shortening the message here } \[/code\]getnewstext.php: \[code\]<?php include_once ('simple_html_dom.php'); $url = $_GET['url']; $html = file_get_html(''.$url.''); $article = $html->find('div[class=newsItem]'); $a = str_get_html(implode("\n", (array)$article)); //parse the article echo '{"item":'. json_encode($a) .'}';?>\[/code\]I think my problem is how I'm encoding the $a variable in the PHP script. The $a variable contains html tags of all kind...how can I append it in the html file?