简体   繁体   English

ajax调用需要用户名和密码

[英]ajax call needs username and password

I'm an Ajax newbie, so that might explain my question. 我是Ajax新手,所以这可以解释我的问题。

I'm doing the following call 我正在打以下电话

                   $.ajax({
                   url: '<?php echo site_url('something/somethingelse')?>',
                   type:'POST',
                   username: 'username',
                   password: 'password',
                   data: { parm1 : 'A', 
                           parm2 : 1,
                           parm3 : 2 }, 
                   dataType: 'json',
                   success: function(output_string){
                   }

username and password are the username and password I use to sign into my server. 用户名和密码是我用来登录服务器的用户名和密码。

how can i represent them in the javascript securely? 如何在JavaScript中安全地表示它们? i know i can store them in variables and use the variables in the Ajax call - but the variables will exist in a javascript file and be visible to anyone who can use a debugger that allows you to view the javascript. 我知道我可以将它们存储在变量中并在Ajax调用中使用变量-但是变量将存在于javascript文件中,并且任何可以使用允许您查看javascript的调试器的人都可以看到。

is there a way to hide certain javascript files? 有没有办法隐藏某些javascript文件? does javascript have the equivalent of a properties file? javascript是否具有相当于属性文件的内容?

turns out this was a url conflict. 原来这是网址冲突。

the ajax call was accessing a url, let's call it some.domain/stats ajax调用正在访问一个URL,我们称它为some.domain / stats

the hosting provider offers a free Statistics page that is password protected. 托管服务提供商提供了一个免费的统计页面,该页面受密码保护。 its url is also some.domain/stats 它的网址也是some.domain / stats

when my app accessed some.domain/stats, thru some weird routing I don't understand, I was directed to the password protected one. 当我的应用访问some.domain / stats时,通过一些我不理解的奇怪路由,我被定向到受密码保护的路由。

when i changed the url the ajax call was accessing to something like some.domain/nameOtherThanStats then everything worked fine. 当我更改URL时,ajax调用正在访问诸如some.domain / nameOtherThanStats之类的东西,那么一切工作正常。

no htaccess changes needed. 无需htaccess更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM