开发者

Cakephp ajax request invalid url

i have a vi开发者_JAVA百科ew page in which i have to load different views according to the option selected in a selecbox. But my problem is that the url to which ajax request is sent is not correct. The correct path to be formatted is like this http://pc12/cakephp/users/getView but the ajax request goes to http://pc12/users/getview. What is my problem here?? My code is below:

jQuery('#ptype').change(function(){ 
var param = "id="+jQuery(this).val();
jQuery.ajax({
        type: "POST",
        url: "/users/getView",
        data: param,
        dataType: "text",
        success: function(data){                    
                                                                             if(data)                                        jQuery('#profile_info').html(data);                                                }
}); 

});


write complete address:

/AppName/Controller/Action/

you can use firebug for debug any ajax requests. it's very helpful.


Problem is the first front slash as I think. url: "**/**users/getView",

in url: remove the first front slash(/) before users and it will work fine. I am using the same format without any problem. It will be like. url: "users/getView",

it is easy and clear to use than your replacement: Html->url(array('controller' => 'users', 'action' => 'getView')); ?>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜