[英]Uncaught SyntaxError: Unexpected token ILLEGAL
I am encountering a problem similar to this: Uncaught SyntaxError: Unexpected Token - jQuery - Help! 我遇到类似的问题: 未捕获的SyntaxError:意外的令牌-jQuery-帮助!
I am using CakePHP 2.x to generate a jquery AJAX request. 我正在使用CakePHP 2.x生成jquery AJAX请求。 It works fine on my local setup, but fails on a production server, giving me an uncaught SyntaxError:
它在我的本地设置上运行良好,但在生产服务器上失败,给了我未捕获的SyntaxError:
Uncaught SyntaxError: Unexpected token ILLEGAL Uncaught SyntaxError:意外的令牌非法
This is the PHP: 这是PHP:
// Get the select element by its generated id attribute.
echo $this->Js->get('#'.$equipment_code)->event(
// Change in the dropdown selection
'change',
// Request an array of compatible brands (match model type)
$this->Js->request(
array('controller'=>'builds','action'=>'ajax_brands'),
// Update the associated brand dropdown
array('update' => $hashed_brand_code, 'dataExpression' => true, 'data' => '$("#'.$equipment_code.'").serialize()')
)
);
Which generates this script: 生成此脚本的代码:
<script type="text/javascript">
//<![CDATA[
$(document).ready(function () {
$("#equipment-14-0").bind("change", function (event) {
$.ajax({
data:$("#equipment-14-0").serialize(),
dataType:"html",
success:function (data, textStatus) {
$("#brand-14-0").html(data);},
url:"\/proj\/eztek-dev\/builds\/ajax_brands"
});
return false;
});
$("#brand-14-0").bind("change", function (event) {
$.ajax({
data:$("#brand-14-0,#equipment-14-0").serialize(),
dataType:"html",
success:function (data, textStatus) {
$("#model-14-0").html(data);
},
url:"\/proj\/eztek-dev\/builds\/ajax_models"
});
return false;
});
$("#equipment-14-2").bind("change", function (event) {
$.ajax({
data:$("#equipment-14-2").serialize(),
dataType:"html",
success:function (data, textStatus) {
$("#brand-14-2").html(data);
},
url:"\/proj\/eztek-dev\/builds\/ajax_brands"
});
return false;
});
$("#brand-14-2").bind("change", function (event) {
$.ajax({
data:$("#brand-14-2,#equipment-14-2").serialize(),
dataType:"html",
success:function (data, textStatus) {
$("#model-14-2").html(data);
},
url:"\/proj\/eztek-dev\/builds\/ajax_models"
});
return false;});
});
//]]>
</script>
And here is the 这是
I'd really appreciate any help you can offer, if there is any other information that would be useful, please let me know and I will put it up here asap. 非常感谢您可以提供的任何帮助,如果还有其他有用的信息,请告诉我,我将在此处尽快提出。
Thank you! 谢谢!
EDIT: 编辑:
Thank you all for your help. 谢谢大家的帮助。 I have fixed the uncaught syntax error by removing unaccepted characters in the js files, however the AJAX still doesn't work on the production server.
我通过删除js文件中不可接受的字符来修复了未捕获的语法错误,但是AJAX仍然无法在生产服务器上运行。 I get the following error in the console:
我在控制台中收到以下错误:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
{Domain name} /proj/eztek-dev/builds/ajax_brands?data%5BEzcomponent%5D%5B2%5D%5Bezmodel_type_id%5D=5
(source: resaraos.com ) (来源: resaraos.com )
Could something be going wrong with the serialize()? serialize()会出问题吗?
I just want to point out that the way you generate your php code is quite im-practical. 我只想指出,您生成PHP代码的方式是不切实际的。
$arr1 = array(
'controller'=>'builds',
'action'=>'ajax_brands'
);
$arr2 = array(
'update' => $hashed_brand_code,
'dataExpression' => true,
'data' => '$("#'.$equipment_code.'").serialize()'
);
$jsRequest = $this->Js->request($arr1, $arr2);
$jsGet = $this->Js->get('#'.$equipment_code)->event('change', $jsRequest); // Change in the dropdown selection & update the associated brand dropdown
$echo $jsGet;
Something like would make sense. 这样的事情将是有道理的。
Sorry for answering an old post (without really answering with a real answer to the question), this just really pierced my eyes. 很抱歉回答一个旧帖子(没有真正回答问题的真实答案),这真让我耳目一新。
Late hint for anyone stumbling upon this question: 有人对此问题绊脚石的最新提示:
This particular error is not specified by Chrome. Chrome未指定此特定错误。 Use Firefox (Firebug console) to get more info about the error.
使用Firefox(Firebug控制台)获取有关该错误的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.