解决双重网址问题..? [英] Solving Dual URL Problem..?

查看:93
本文介绍了解决双重网址问题..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用cakephp,我有2个链接:

I am using cakephp I have 2 links:

<a href="#" tabindex="1" onclick="base_load_demo1('http://www.boxyourtvtrial.com/widget/beer/main/');" >beer</a>
<a href="#" tabindex="2" onclick="base_load_demo('http://www.boxyourtvtrial.com/widget/cocktail/main/');">cocktail</a>

使用以下JavaScript:

With the following JavaScript:

var Url1 = "http://www.boxyourtvtrial.com/widget/cocktail/main/";
var Url2 = "http://www.boxyourtvtrial.com/widget/beer/main/";
var Url3 = "http://www.boxyourtvtrial.com/widget/beer/mini/";

function base_load_demo(Url) {
  remoteCall(Url1,"","mainLeftContent");
  //remoteCall("SCRIPT_PATH","QUERY_STRING","TARGET_FUNCTION");
}

function base_load_demo1(Url2) {
  remoteCall(Url2,"","mainLeftContent");
  //remoteCall("SCRIPT_PATH","QUERY_STRING","TARGET_FUNCTION");
}

当我单击第一个链接时,它通过ajax调用显示其内容,但是当我单击第二个链接其给出的错误如下:

When I click on the first link it's showing its content through ajax call but when I click on the second link its giving error as follows:


缺少控制器

Missing Controller

错误:找不到Http:Controller。

Error: Http:Controller could not be found.

错误:在文件中创建以下类Http:Controller:app / controllers / http:controller.php

Error: Create the class Http:Controller below in file: app/controllers/http:controller.php


<?php
class Http:Controller extends AppController {

    var $name = 'Http:';
}
?>



注意:如果要自定义此错误消息,请创建应用程序/视图/错误/ missing_controller.ctp

Notice: If you want to customize this error message, create app/views/errors/missing_controller.ctp

并在FireFox控制台选项卡中

and in FireFox console tab


POST http://www.boxyourtvtrial.com /widget/beer/main/http://www.boxyourtvtrial.com/widget/cocktail/main/

我们如何解决

var xmlHttp;
var uri = "";
var callingFunc = "";
var sResponse = new Array();



function remoteCall(sUrl, sQueryStr, sCalledBy)
{
    alert(sUrl);
    var resStr = "";
var str = " { ";
if(sQueryStr != "") {
    var arr1 = new Array();
    arr1 = sQueryStr.split("&");
    if(arr1){
        for(i=0;i<=arr1.length;i++)
        {
            if(arr1[i] && arr1[i] != "") 
                              {
                var arr2 = new Array();
                arr2 = arr1[i].split("=");
                str += arr2[0]+":'"+arr2[1]+"' ,";
                
              }
        }
    }
}                   

    str += " tp: 'tp' } ";
      
      
    $.ajax({
        type: "GET",     
        url: sUrl,
        data: sQueryStr,
        dataType: "html",
        success: function(data) {
            $("#"+sCalledBy).html(data);
            //jih(sCalledBy,data);
        }
    });
      
  /*    $.get(sUrl,sQueryStr,function(data) {   
    jih(sCalledBy,data);
    });*/
}

function jih(divid,data)
{
         if(document.getElementById(divid))
                     document.getElementById(divid).innerHTML=data;
    }


推荐答案

加载的页面数:

<script type="text/javascript" src="http://www.boxyourtvtrial.com/widget/cocktail/main/js/common.js"></script>

。 common.js内部有一个名为 remoteCall 的函数,该函数将覆盖您的本地remoteCall函数。

in the header. Inside common.js is a function called remoteCall, which is overwriting your local remoteCall function.

common.js内部的remoteCall函数会添加

The remoteCall function inside common.js adds

var url= WIDGET_WEG_PATH+scr_url;

其中 WIDGET_WEG_PATH = http://www.boxyourtvtrial.com/widget/beer/main/

where WIDGET_WEG_PATH = "http://www.boxyourtvtrial.com/widget/beer/main/"

scr_url = http://www.boxyourtvtrial.com / widget / beer / main / (新remoteCall函数的第一个参数)

and scr_url = "http://www.boxyourtvtrial.com/widget/beer/main/" (the first parameter of the new remoteCall function)

这就是为什么获取url'加倍。

This is why you are getting the url 'doubled' in the post.

解决方案:

将本地remoteCall函数重命名为不同的名称。

Rename local remoteCall function to something that is distinct.

这篇关于解决双重网址问题..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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