Php 在jquery post调用中不能要求_一次
如果我试图在需要的文件实例化php对象并获取该对象的属性时要求_,那么我将使用jQueryPost调用来返回SyntaxError意外标记。奇怪的是,它似乎在我的远程服务器上工作,但在我的本地测试服务器上却不工作。代码如下: 进行Jquery调用的php文件的一部分:Php 在jquery post调用中不能要求_一次,php,jquery,ajax,post,require-once,Php,Jquery,Ajax,Post,Require Once,如果我试图在需要的文件实例化php对象并获取该对象的属性时要求_,那么我将使用jQueryPost调用来返回SyntaxError意外标记。奇怪的是,它似乎在我的远程服务器上工作,但在我的本地测试服务器上却不工作。代码如下: 进行Jquery调用的php文件的一部分: <script type="text/javascript"> getSelectData() </script> <!-- Dynamiclygenerate the ema
<script type="text/javascript"> getSelectData() </script>
<!-- Dynamiclygenerate the emailadress for the first referens in the list -->
<div id="customer_ref_id">
<label for="customer_name">Kund:</label>
<p><?php echo $customer->customer_name; ?> </p>
<a href="#" class="toprghtimg"> <img src="../images/back.png"/></a>
<p class="instruction">
Välj Kundreferens i listan nedanför.
Finns ej din referens så skapa en ny referens knuten till
kunden genom att klicka på knappen nere till höger.
</p>
<div class="clearLeft"></div>
<label for="customer_ref_id">Kundreferens:</label>
<select name="customer_ref_id" id="customer_ref_id">
<?php
foreach ($customerRefs as $customerRef) { ?>
<option value="<?php echo $customerRef->id; ?>">
<?php echo $customerRef->full_name(); ?>
</option>
<?php } ?>
</select>
<input type="button" value="Skapa ny Kundreferens" onclick="getNewCustRef()" />
<div class="clearLeft"></div>
<div id="customerRefInfo"> <label>E-post:</label><p>-Ej registrerad-</p></div>
<input type="button" class="after_p" value="Ändra referensens data" onclick="changeRefData()" />
</div>
getSelectData()
昆德:
Välj Kundreferens i listan nedanför。
芬兰人和其他人的关系
昆登·热那姆·克莱卡·普克纳彭·内尔·蒂尔·霍格。
昆德雷弗伦斯:
您应该运行phpinfo();查看两个PHP版本都包含JSON支持和所有其他所需的库
然后我会再次检查以确保该文件位于正在查看的目录中。在本例中,它是祖父母目录(../../file.php)
然后我会创建几个文件,看看是否可以让include/require_once函数正常工作
有时使用远程/本地时,您很容易混淆。就在今天,我正在编辑一个文件的本地副本,因为远程文件没有显示任何更改,我的头发都被撕掉了 确切的错误消息是什么?显然有人认为您不能在jQuery帖子中使用“require\u once”。你可以。如果你不知道你在说什么,请不要把这个标记为不正确的答案。错误的信息比没有信息更糟糕。
function getSelectData() {
var formData = $("#customer_ref_id select").serialize();
$.ajax({
url : 'getSelectData.php',
type : 'POST',
dataType: 'json',
data : formData,
success: function( data ) {
$('#customerRefInfo p').replaceWith('<p>'+data+'</p>' ) ;
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown); }
});
<?php require_once("../../includes/initialize.php");
$customer_ref_id = $_POST['customer_ref_id']; // Selected customer_ref_id
$custRef = CustomerRef::find_by_id($customer_ref_id);
$custRefEmail = $custRef->e_post;
echo json_encode($custRefEmail);
?>