dtl4521 2012-09-18 21:51
浏览 89

ajax jquery php提交

i have a simple form in php that has a user textbox and pass textbox we'll call it login.php. I have another php page, let's call it sendtologin.php, that i want to 'send' the credentials via jquery ajax to post to login.php. The login.php is on server1 and sendtologin.php is on server2. when i try to load the sendtologin.php i get a status code of 0 and error. here is my script.

$(document).ready(function () {
        $.ajax({
            type: "POST",
            url: "http://server1/login.cgi",
            data: { lang_changed: "no", username: "me", password: "me" },
            success: function (data) { alert("success!"); },
            error: function (request, type, errorThrown) {
                alert("request: " + request.status + 
                      "
requestText: " + request.statusText +
                      "
Type: " + type + 
                      "
Exception: " + errorThrown); }
        });
    });

what am i doing wrong?

  • 写回答

2条回答 默认 最新

  • doty58493 2012-09-18 22:22
    关注

    Your best bet is to pass the login credentials into your "login.php" (if its on the same server as your ajax call) and then use PHP's cURL function to pass the posted variables to your second domain's "login2.php".

    I use this gateway / passthrough technique ALOT and it works for getting around those pesky cross-domain-policy issues.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型