【问题标题】:AJAX to JQuery Conversion AssistanceAJAX 到 JQuery 转换帮助
【发布时间】:2013-12-24 05:18:19
【问题描述】:

有人愿意帮助我完成这个脚本吗?

我只需要有人拿这个 AJAX 的 sn-p 并基本上用 jQuery 重新编程,这样我就可以研究它并了解更多关于如何使用 jQuery 的信息。这是我正在使用的 AJAX 的当前工作位,我认为如果我可以在 jQuery 中看到它,它将开始我的学习过程......

所以,如果有人这么好心,这就是脚本:

function CreateXmlHttpObject() { //function to return the xml http object
    var xmlhttp = false;
    try {
        xmlhttp = new XMLHttpRequest(); //creates a new ajax object
    } catch(e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); //this is for IE browser
        } catch(e) {
            try {
                req = new ActiveXObject("Msxml2.XMLHTTP"); //this is for IE browser
            } catch(e1) {
                xmlhttp = false; //error creating object
            }
        }
    }
    return xmlhttp;
}

function getMetaID(strURL) {
    var req = CreateXmlHttpObject(); // function to get xmlhttp object
    if(req) {
        req.onreadystatechange = function () {
            if(req.readyState == 4) { //data is retrieved from server
                if(req.status == 200) { // which reprents ok status                    
                    document.getElementById('meta_id').innerHTML = req.responseText; //put the results of the requests in or element
                } else {
                    alert("There was a problem while using XMLHTTP:\n");
                }
            }
        }
        req.open("GET", strURL, true); //open url using get method
        req.send(null); //send the results
    }
}

这是在调用函数的页面上(PHP):

echo '<select name="meta_id" onChange="getMetaID('."'".'http://www.mysite.com/backoffice/meta_tags/ajaxpageid.php?meta_id='."'".'+this.value)">';

之后是&lt;div&gt;

希望这是足够的信息来使它有意义。我当然感谢任何帮助...

【问题讨论】:

    标签: jquery html ajax forms


    【解决方案1】:
       <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
      <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
    

    在使用 jQuery 之前添加这些文件

    $.ajax(serverUrl, {
       type: "POST",
       data:{ strURL:strUR},
       statusCode: {
          200: function (response) {           
          },
          201: function (response) {           
          },
          400: function (response) {
           },
          404: function (response) {
           );
          }
       }, success: function () {
    
       },
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多