Response title
This is preview!
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:
<head>
<script src="js/newstext.js"></script>
</head>
<body>
<div data-role="page" id="newstext">
<div data-role="content">
<div id="textcontent"></div>
</div>
</div>
</body>
newstext.js:
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; console.log(newstext);
$('#textcontent').text(newstext);
$('#textcontent').trigger('create');
}
function getUrlVars(){
//it displays in the alert perfectly, shortening the message here
}
getnewstext.php:
<?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
header("Content-type: application/json");
echo '{"item":'. json_encode($a) .'}'; ?>
In the console, there is no response. I know this question is borderline jQuery and PHP, but I hope someone can help with this issue. Thanks
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
<div data-role="page">
<div data-role="content">
<ul data-role="listview" data-theme="c" data-dividertheme="b">
<li data-role="list-divider">Top News</li>
<?php include_once ('simple_html_dom.php');
$html = file_get_html('http://www.example.com');
foreach ($html->find('*.overridable a[class=title]') as $main){
echo '<li><a href="news.php?url='.urlencode($main->href).'" data-transition="slidedown">'.$main->plaintext.'</a></li>';
} ?>
<li data-role="list-divider">Other News</li>
<?php include_once ('simple_html_dom.php');
$html = file_get_html('http://www.example.com');
foreach ($html->find('div[class=river-post yui-u] h2 a[href*=example]') as $ret){
echo '<li><a href="othernews.php?url='.urlencode($ret->href).'" data-transition="slidedown">'.$ret->plaintext.'</a></li>';
} ?>
</ul>
</div>
© 2013 jQuery Foundation
Sponsored by and others.