【问题标题】:URL variable not being set in PHP when using jquery mobile使用 jquery mobile 时未在 PHP 中设置 URL 变量
【发布时间】:2013-01-20 22:29:54
【问题描述】:

我有几页,当输入被提交时,它将转到一个 php 文件,该文件检查 url 变量,这可能是 executeeffects.php?option=blockuser

但是当我转到页面时,页面只是在 executeeffects php 文件中显示“未定义”,它有一个检查功能来检查是否设置了变量,如果是,它会回显一件事,如果不是,它会回显另一件事,但是我没有让它回显未定义所以我不知道这是从哪里来的,代码在下面

谁能告诉我这是 jquery mobile 的问题还是我遗漏了什么?

block.php

<!DOCTYPE html> 
<html> 
<head> 
    <title>Ryan Kelly</title> 

<meta name="viewport" content="width=device-width, initial-scale=1 user-scalable=no"> 

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>

<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script src="effects.js"></script>
    </head> 
    <body> 

    <div data-role="page">

<div data-role="header">
    <h1>Ryan Kelly</h1>
</div><!-- /header -->

<div data-role="content">   
    <label for="basic">Username:</label>
     <input type="text" name="name" id="basic" value="" />
     <input type="text" name="name" id="blocked" value="" />
     <a href="executeeffects.php?option=block" data-role="button" class="button">Submit</a>

     <?php include('listusers.php'); ?>
 </div><!-- /content -->

     </div><!-- /page -->

     </body>
   </html>

执行效果.php

<?php


if(isset($_GET['option'])){

echo 'something is set!';
} else {

echo 'nothing is set!';
}

?>

【问题讨论】:

  • 什么是 var_dump($_GET); executeeffects.php 上的输出
  • 它假设检查是否设置了某些东西,而不是回显一个语句或另一个它只是进入执行效果页面,它说未定义
  • 去掉executeeffects.php里面的代码,换成var_dump($_GET);它有输出吗?
  • 它说 undefined ,但是当我刷新页面时它说 array(1) { ["option"]=> string(5) "block" }
  • 您的问题中提供的代码是 executeeffects.php 中唯一的代码吗?

标签: php jquery html jquery-mobile


【解决方案1】:

你说“我有几页,当输入被提交时,它将转到一个 php 文件,该文件检查 url 变量,这可能是 executeeffects.php?option=blockuser

这个:

<input type="text" name="name" id="basic" value="" />
 <input type="text" name="name" id="blocked" value="" />
 <a href="executeeffects.php?option=block" data-role="button" class="button">Submit</a>

不会提交输入的值,除非您使用某种类型的 jQuery,而您没有发布在这种情况下,这需要以不同的方式完成。

要提交您需要使用&lt;form&gt; 的输入值

【讨论】:

    猜你喜欢
    • 2014-02-20
    • 1970-01-01
    • 1970-01-01
    • 2011-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-11
    相关资源
    最近更新 更多