PHP AJAX заявка не се изпълнява но не мога да разбера защо

C++ JAVA
Post Reply
Knoppix_
Турист
Турист
Posts: 322
Joined: Mon Aug 24, 2009 11:55 am

PHP AJAX заявка не се изпълнява но не мога да разбера защо

Post by Knoppix_ » Wed Jun 19, 2013 8:01 am

Здравейте,
имам следният проблем имам един инпут който проверявам и който искам ако е изпълнено едно условие да ми излизат две съобщения. Стигнах до някъде т.е уж работи но не мога да визуализирам двете съобщеният там където искам. T.e проблема е следният няма визуализация ...върху полето .. така че да ми излиза предупреждение
Ето кодовете
това е jquery

Code: Select all

$(document).ready(function(){
$("#vlekach_number").keyup(function() {
var name = $('#vlekach_number').val();
if(name=="")
{
$("#disp").html("");
}
else
{
$.ajax({
type: "POST",
url: "pages/user_check.php",
data: "vlekach_number="+ name ,
success: function(html){
$("#disp").html(html);
}
});
return false;
}
});
});
Това е сайта с формата с която въвеждам информацията

Code: Select all

`<style type="text/css">
		#fm&#123;
			margin&#58;0;
			padding&#58;10px 30px;
		&#125;
		.ftitle&#123;
			font-size&#58;14px;
			font-weight&#58;bold;
			color&#58;#666;
			padding&#58;5px 0;
			margin-bottom&#58;10px;
			border-bottom&#58;1px solid #ccc;
		&#125;
		.fitem&#123;
			margin-bottom&#58;5px;
		&#125;
		.fitem label&#123;
			display&#58;inline-block;
			width&#58;80px;
		&#125;
	</style>
<div style="float&#58;right; margin-right&#58;25px; margin-top&#58;-32px;">
<a href="?page=kasova-kniga-main"><img src="images/close.png" border="0" /></a>
</div>
	<table id="tt" class="easyui-datagrid" style="width&#58;860;height&#58;400px"
			url="pages/get_advance.php"
			title="Получени служебни аванси във фирма Петко Ангелов БГ ЕООД" iconCls="icon-search" toolbar="#tb"
			rownumbers="true" pagination="true" singleSelect="true">
		<thead>
			<tr>
				<th field="vlekach_number" width="80" align="center">Влекач</th>
				<th field="trailer_number" width="80" align="center">Ремарке</th>
                <th field="driver_name" width="90">Шофьор</th>
                <th field="slujeben_avans" width="90">Служебен аванс</th>
                <th field="start_date" width="90">Дата</th>
                <th field="end_date" width="90">Дата на отчитане</th>
                <th field="destination" width="90">Дестинация</th>
                <th field="zabelejka" width="90">Забележка</th>
			</tr>
		</thead>
	</table>
	<div id="tb" style="padding&#58;3px">
    <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onClick="newAdvance&#40;&#41;">Нов запис</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onClick="editAdvance&#40;&#41;">Редакция</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onClick="removeAdvance&#40;&#41;">Изтриване</a>
		<span>Влекач номер&#58;</span>
		<input id="itemid" style="line-height&#58;26px;border&#58;1px solid #ccc;">
		<span>Дата&#58;</span>
		<input id="productid" style="line-height&#58;26px;border&#58;1px solid #ccc">
        <a href="#" class="easyui-linkbutton" plain="true" onClick="doSearch&#40;&#41;" iconCls="icon-search">Филтър</a>
	</div>
 <div id="dlg" class="easyui-dialog" style="width&#58;400px;padding&#58;10px 20px"
			closed="true" buttons="#dlg-buttons">
		<form id="fm" method="post" novalidate>
        <div class="fitem"> <label>Влекач&#58;</label>
        <select name="vlekach_number" class="easyui-combobox" required="true" style="width&#58;140px;" />
                    <?php
                        $user_name = "root";
                        $password = "";
                        $database = "programa";
                        $server = "localhost";
                        //connect to host
						$db_handle = mysql_connect&#40;$server,$user_name,$password&#41;;
                        if &#40;!$db_handle&#41;&#123;
                            die&#40;'Не мога да се свържа&#58; ' . mysql_error&#40;&#41;&#41;;
                        &#125;
                        //connect to database
                        mysql_select_db&#40;$database, $db_handle&#41;;
                        //collect user names
						mysql_query&#40;"SET CHARACTER SET utf8"&#41;;
                        $query = mysql_query&#40;"SELECT * FROM vlekachi"&#41;
                            or die&#40;mysql_error&#40;&#41;&#41;;
                        $row_count = mysql_num_rows&#40;$query&#41;;
                        for &#40;$i=0; $i<$row_count; $i++&#41; &#123;
                            $user = mysql_fetch_array&#40;$query&#41;;
                            echo&#40;"<option value=\"".$user&#91;'vlekach'&#93;."\">".$user&#91;'vlekach'&#93;."</option>"&#41;;
                        &#125;
                        mysql_close&#40;$db_handle&#41;;
                    ?>
</select></div>
        <div class="fitem"><label>Ремарке&#58;</label>
        <select name="trailer_number" class="easyui-combobox" required="true" style="width&#58;140px;"  >
                    <?php
                        $user_name = "root";
                        $password = "";
                        $database = "programa";
                        $server = "localhost";
                        //connect to host
						$db_handle = mysql_connect&#40;$server,$user_name,$password&#41;;
                        if &#40;!$db_handle&#41;&#123;
                            die&#40;'Не мога да се свържа&#58; ' . mysql_error&#40;&#41;&#41;;
                        &#125;
                        //connect to database
                        mysql_select_db&#40;$database, $db_handle&#41;;
                        //collect user names
						mysql_query&#40;"SET CHARACTER SET utf8"&#41;;
                        $query = mysql_query&#40;"SELECT * FROM remarketa"&#41;
                            or die&#40;mysql_error&#40;&#41;&#41;;
                        $row_count = mysql_num_rows&#40;$query&#41;;
                        for &#40;$i=0; $i<$row_count; $i++&#41; &#123;
                            $user = mysql_fetch_array&#40;$query&#41;;
                            echo&#40;"<option value=\"".$user&#91;'remarke'&#93;."\">".$user&#91;'remarke'&#93;."</option>"&#41;;
                        &#125;
                        mysql_close&#40;$db_handle&#41;;
                    ?>
</select></div>
		<div class="fitem"><label>Шофьор&#58;</label>
         <select name="driver_name" class="easyui-combobox" required="true" style="width&#58;140px;"  >
                    <?php
                        $user_name = "root";
                        $password = "";
                        $database = "programa";
                        $server = "localhost";
                        //connect to host
						$db_handle = mysql_connect&#40;$server,$user_name,$password&#41;;
                        if &#40;!$db_handle&#41;&#123;
                            die&#40;'Не мога да се свържа&#58; ' . mysql_error&#40;&#41;&#41;;
                        &#125;
                        //connect to database
                        mysql_select_db&#40;$database, $db_handle&#41;;
                        //collect user names
						mysql_query&#40;"SET CHARACTER SET utf8"&#41;;
                        $query = mysql_query&#40;"SELECT * FROM shofiori"&#41;
                            or die&#40;mysql_error&#40;&#41;&#41;;
                        $row_count = mysql_num_rows&#40;$query&#41;;
                        for &#40;$i=0; $i<$row_count; $i++&#41; &#123;
                            $user = mysql_fetch_array&#40;$query&#41;;
                            echo&#40;"<option value=\"".$user&#91;'ime'&#93;."\">".$user&#91;'ime'&#93;."</option>"&#41;;
                        &#125;
                        mysql_close&#40;$db_handle&#41;;
                    ?>
</select>
        </div>
		<div class="fitem"><label>Служебен аванс&#58;</label><input name="slujeben_avans" class="easyui-validatebox" required="true"></div>
		<div class="fitem"><label>Дата на получаване&#58;</label><input name="start_date" class="easyui-datetimebox"  required="true"></div>
        <div class="fitem"><label>Дата на отчитане&#58;</label><input name="end_date" class="easyui-datetimebox"></div>
        <div class="fitem"><label>Дестинация&#58;</label><input name="destination" class="easyui-validatebox"></div>
        <div class="fitem"><label>Забележка&#58;</label><input name="zabelejka" class="easyui-validatebox"></div>
        <div id="disp" style="border&#58;1px solid #000;"></div>
		</form>
	</div>
	<div id="dlg-buttons">
		<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onClick="saveAdvance&#40;&#41;">Запис</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onClick="javascript&#58;$&#40;'#dlg'&#41;.dialog&#40;'close'&#41;">Отказ</a>
	</div>
А това е php файла за проверка

Code: Select all

<?php
include&#40;'conn.php'&#41;;
if&#40;isset&#40;$_POST&#91;'vlekach_number'&#93;&#41;&#41;
&#123;
$name=$_POST&#91;'vlekach_number'&#93;;
$query=mysql_query&#40;"select * from kasova_kniga where vlekach_number='$name' AND start_date !='' "&#41;;
$row=mysql_num_rows&#40;$query&#41;;
if&#40;$row==0&#41;
&#123;
echo "<span style='color&#58;green;'>Niama neotcheteni avansi</span>";
&#125;
else
&#123;
echo "<span style='color&#58;red;'>Внимание! За този влекач има неотчетени аванси!</span>";
&#125;
&#125;
?>

Post Reply