如何做 我在由 jquery ajax 调用的页面中触发静态方法


how to do i trigger a static method in a page that is called by jquery ajax

我的问题是我有一个下拉框,我根据我的选择加载内容。但是,在我获取内容的其中一个页面中,我有一个静态方法,我需要在显示内容之前调用该方法。该方法所做的只是检查该值是否已在会话中设置。如果是填充字段。如果我使用 jquery ajax 加载内容,看起来该方法不会触发。这是我根据我的选择加载的 html:

    <table>
<tr>
<td><label class="required">Enter Current Number:</label></td><td><input type="text" size=13 id="current_number"  name="current_number" value="<?php echo Util::getSessionValuebySessionName("phonePorting", "current_number"); ?>"></td>
</tr>
<tr><td colspan="2"><strong>Please Enter the Address associated to your current phone number</strong>
NOTE: You may only keep your current phone number if the address of your current phone number is in the same state as the address where you are signing up for CenturyLink service. </td></tr>
<tr>
<td width=20%><label class="required">Address Line 1:</label></td><td><input type="text" size=25  id="address_line1"  name="address_line1" value="<?php echo Util::getSessionValuebySessionName("phonePorting", "address_line1"); ?>" ></td>
</tr>
<tr>
<td>Address Line 2:</td><td><input type="text" size=25  id="address_line2"  name="address_line2" value="<?php echo Util::getSessionValuebySessionName("phonePorting", "address_line2"); ?>"></td>
</tr>
<tr>
<td><label class="required">Apartment:</label></td><td><input type="text" size=5  id="Apartment"  name="Apartment"   value="<?php echo Util::getSessionValuebySessionName("phonePorting", "Apartment"); ?>"></td>
</tr>
<tr>
<td><label class="required">City:</label></td><td><input type="text" size=15  id="City"  name="City" value="<?php echo Util::getSessionValuebySessionName("phonePorting", "City"); ?>"></td>
</tr>
<tr>
<td><label class="required">State:</label></td><td><select  id="State"  name="State"   >
<option value="">Select a State</option>
<?php foreach (Util::getStatesCodes() as  $key => $value) {?>
<option value="<?php echo $key; ?>" <?php Util::getSessionValuebySessionName("phonePorting", "City")==$key)echo "selected";?>><?php echo $key; ?></option>  
<?php }?>
</select>
</td>
</tr>
<tr>
<td><label class="required">ZipCode:</label></td><td><input type="text" size=15  id="Zipcode"  name="Zipcode"  value="<?php echo Util::getSessionValuebySessionName("phonePorting", "Zipcode"); ?>" ></td>
</tr>
</table>

下面是静态方法:

    public static function getSessionValuebySessionName($ssessionName, $keyName){
    if(!empty($_SESSION[$ssessionName][session_id()][0][$keyName]))
    {
        return $_SESSION[$ssessionName][session_id()][0][$keyName];
    }

因此,当我在下拉列表中进行选择时,如果会话值在 html 内容中不为空,则我几乎想做的是加载会话值(在文本字段中)。希望这是有道理的。

谢谢。

问题解决了。我忘了在构造函数中启动会话.....