私のアプリケーションでいくつかのPHPファイルを実行する必要があります、私はそれらを私のウェブサイトにアップロードしました。私はここで記事を読んだ、私は私のファイルのために同じことをしたが、私のPHPファイルは、AJAXで動作しているので、私はそれを実行できませんでした。私は可能な限りすべての方法を試しましたが、私はまだ誤解されています。Phone Gapでphpファイルを実行するには?
search.htmlはjs経由でリンクを作成し、このリンクをget_data.phpに渡し、同じページに結果をresults
タグで示します。
search.htmlの
function abc(target_url) {
target_url = target_url||(generate_url()||"http://nces.ed.gov/collegenavigator/?");
ajax = window.XMLHttpRequest?(new XMLHttpRequest()):(new ActiveXObject("Microsoft.XMLHttp"));
ajax.onreadystatechange=function() {
if(ajax.readyState===4) {
html_data = ajax.responseText;
//Do stuff with it like parsing, etc
//alert(html_data);
window.loading.style.visibility="hidden";
document.getElementById("results").innerHTML = html_data ||"We're sorry";
}
};
ajax.open("GET", "./get_data.php?url="+encodeURIComponent(target_url), true);
ajax.send(null);
window.loading.style.visibility="visible";
}
これはget_data.php
<?php
include_once('simple_html_dom.php');
$target_url = $_REQUEST["url"];
$html = new simple_html_dom();
$html->load_file($target_url);
$gokhan='arik';
#$anchors = array_diff($html->find('table[class=resultsTable] a'), $html->find('td[class=addbutton] a'));
$h2 = $html->find('table[class=resultsTable] h2');
$ipeds = $html->find('p[class=ipeds hoverID]');
foreach($html->find('div[id=ctl00_cphCollegeNavBody_ucResultsMain_divMsg]') as $nOfResults){
echo "<b>".strip_tags($nOfResults)."</b>";
}
$loca = $html->find('table[class=itables] tbody tr td[class=pbe]');
for($i=0;$i<count($h2);$i++) {
if(strip_tags($h2[$i])=="") continue;
#echo strip_tags(strtr($ipeds[$i], array(" "=>" ")));
$iped = explode(" ", strip_tags(strtr($ipeds[$i], array(" "=>" "))));
echo "<li data-theme='c' class='ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-btn-up-c'>
<div class='ui-btn-inner ui-li'>
<div class='ui-btn-text'>
<a href='search2.php?id=".$iped[2]."' class='ui-link-inherit'><h3 class='ui-li-heading'>".strip_tags($h2[$i])."</h3><p class='ui-li-desc'>".strip_tags(strtr($loca[$i], array('</h2>'=>'</h2> ')))."</p></a>
</div>
<span class='ui-icon ui-icon-arrow-r ui-icon-shadow'/>
</div>
</li>
";
}
ているのですか?>
を行うにはjQueryのフレームワークを使用する方法の詳細については
私は 'PhoneGap'は、あなたが電話でPHPを実行することができます...あなたがホストする必要がありますとは思いませんPHPを自分のサーバーにインストールし、[HTTP_Access_control](https://developer.mozilla.org/En/HTTP_access_control)を設定して、PhoneGapアプリからXHRリクエストを行うことができます。 – Sathvik
それは私が言ったことです。あなたは電話でPHPを、サーバ上の私のPHPファイルを実行することはできません。私はそれらを接続するのに苦労します。 別の投稿では、このようなものを使用すると言います。それは動作していません。 '$( '#content').load( 'http://www.example.com/test.php');' –