0
나는 페이지가 있고 전체 page.Div를 새로 고치지 않고 div를 새로 고침하고 싶습니다. 다른 xml 파일에서 더 큰 가격을 계산하는 PHP 파일에서 데이터를 가져옵니다. 방법은 아약스 요청입니다.아약스 요청 응답 거짓 데이터
내 아약스 코드 :
<script type="text/javascript">
$(function(){
var name = $("#product").val();
$.ajax({
type: "GET",
url: "maxPrice.php",
dataType: "text",
data: {'product_name' : name},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
},
success:function(result) {
alert(result);
}
});
});
</script>
PHP 파일 : 나는 아약스의 데이터가 이와 맞아요 그 응답이 있는지 확인하는 경고가 아약스의 성공에
<?php
$product_name = $_GET['product_name'];
$loop = 0;
$auction_price_db = 0;
$id_product = id_from_product_name($product_name);
$doc = new DOMDocument();
$doc->load('C:/wamp/www/store/connections/auctions.xml');
$xpath = new DOMXPath($doc);
$xml_offers = simplexml_load_file('C:/wamp/www/store/connections/offers.xml');
$xml_auctions = simplexml_load_file('C:/wamp/www/store/connections/auctions.xml');
foreach ($xml_auctions->auction as $auction){
if ($auction->auction_id == $id_product) {
$auction_price_db = (string)$auction->start_price;
$item = $loop;
break;
}
$loop++;
}
foreach ($xml_offers->offer as $offer){
if ($offer->id_product == $id_product) {
$user_offer = (string)$offer->price;
if ($user_offer > $auction_price_db) {
$parent = $doc->getElementsByTagName('auction')->item($item);
$query = $xpath->query('start_price',$parent);
$query->item(0)->nodeValue = $user_offer;
$doc->save('C:/wamp/www/store/connections/auctions.xml');
$xml_products = simplexml_load_file('C:/wamp/www/store/connections/products.xml');
foreach ($xml_products->product as $product){
if ($id_product == $product->product_id) {
$product->price = $user_offer;
$xml_products->asXML('connections/products.xml');
}
}
$response = "{\"user_offer\":\"".$user_offer."\"}";
}
}
}
echo <<<HERE_DOC
$response
HERE_DOC;
?>
. 내가 최대 가격에서 모든 코드를 삭제하려고 만 $의 제품 _ 에코 경우 내가?이 응답을받을 이유.
<br />
<font size='1'><table class='xdebug-error xe-fatal-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>(!)</span> Fatal error: Call to undefined function id_from_product_name() in C:\wamp\www\store\maxPrice.php on line <i>6</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0004</td><td bgcolor='#eeeeec' align='right'>692568</td><td bgcolor='#eeeeec'>{main}()</td><td title='C:\wamp\www\store\maxPrice.php' bgcolor='#eeeeec'>..\maxPrice.php<b>:</b>0</td></tr>
</table></font>
그 전 아약스 요청에 전달하면 올바른 데이터를 얻을 수 있습니다.
'정의되지 않은 함수 id_from_product_name() C에서을 : \ WAMP \ www가 \ 저장소 maxPrice.php 라인에 6'에 보인다 \ 문제가 될 수 있습니다.'$ id_product = id_from_product_name ($ product_name);'이 폭파됩니다. – MonkeyZeus
오류가 발생하여 호출 스택을 되돌려 보내고 있습니다. 오류가 바로 있습니다. "치명적인 오류 : C : \ Wamp \ www \ store \ maxPrice.php의 정의되지 않은 함수 id_from_product_name()을 호출하십시오." – Gjohn
왜이 함수가 제대로 작동하는지 압니다 .id_from_product_name은 또 다른 PHP 파일입니다. 나는 그것을 같은 곳에 넣어야합니까? – user3071235