价值回归为未定义 [英] Value is coming back as Undefined

查看:158
本文介绍了价值回归为未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jquery数据表在表上显示结果,然后将ID作为URL参数传递,我们可以向用户显示特定记录的详细信息。



所以但是,我被要求传递一个名为user的第二个url参数,这就是问题。



当我运行代码时,它不再显示详细信息页。



在使用firebug查看代码时,我发现错误说: / p>

john is undefined



john.doe该值显示在url上,看起来更像这样:

  http://mylink.com/viewDetails.php?ID = 1235& userName = john.doe 

任何想法我做错了什么?

  return< a target ='tab'data-tab-name ='#RequestDetails'data-tab-index ='2'href = 'viewDetails.php?rID =
+ oObj.aData [ID] +& userName =+<?php ec ho $ user; ?> +'>+ oObj.aData [ID] +< / a>;


解决方案

您的代码在被PHP解析后看起来像这样:



< a target ='tab'data-tab-name ='#RequestDetails'data-tab-index ='2'href = 'viewDetails.php?rID =+ oObj.aData [ID] +& userName =+ john +'> + oObj.aData [ID] +< / a>



这意味着它正在寻找一个名为 john ,您可以看到它是未定义的。



应该是这样的:



< a target ='tab'data-tab-name ='#RequestDetails'data-tab-index ='2'href ='viewDetails.php?rID =+ oObj .aData [ID] +& userName =<?php echo $ user?>'> + oObj.aData [ID] +< / a>


I am using jquery datatables to display results on a table and then passing ID as URL parameter, we able to display details of a particular record to user.

So far, this works fine.

However, I have been asked to pass a second url parameter called user and this is presenting problems.

When I run the code, it is no longer displaying details page.

Upon reviewing the code using firebug, I found an error that says:

john is undefined.

john.doe is the value being displayed on the url that looks more like this:

http://mylink.com/viewDetails.php?ID=1235&userName=john.doe

Any ideas what I am doing wrong?

return "<a target='tab' data-tab-name='#RequestDetails' data-tab-index='2' href='viewDetails.php?rID="
       + oObj.aData["ID"] + "&userName=" + <?php echo $user; ?> + "'> " + oObj.aData["ID"] + " </a>";

解决方案

Your code looks like this after being parsed by PHP:

<a target='tab' data-tab-name='#RequestDetails' data-tab-index='2' href='viewDetails.php?rID=" + oObj.aData["ID"] + "&userName=" + john + "'> " + oObj.aData["ID"] + " </a>

That means it's looking for a variable called john, which as you can see is undefined.

It should be this:

<a target='tab' data-tab-name='#RequestDetails' data-tab-index='2' href='viewDetails.php?rID=" + oObj.aData["ID"] + "&userName=<?php echo $user?>'> " + oObj.aData["ID"] + " </a>

这篇关于价值回归为未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆