本文介绍了如何在javascript中将元素值(sid和stmp值)作为键值对调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个html页面.

我正在对链接进行ajax调用,并且获取了其中包含sId和sTmp值的html数据.我需要在html页面中将sId和sTmp的所有值作为键值对.

(大约有106个sId和sTmp值)

如何获取sId和sTmp的所有值作为键值对?

包含sId和sTmp值的html数据代码:-

I have an html page.

I am making an ajax call to a link and i get the html data which contains sId and sTmp values in it. I need to get all the values of sId and sTmp as key value pairs in my html page.

(There are about 106 sId''s and sTmp values)

How to get all the values of sId and sTmp as key value pairs ?

Code of html data which contains sId and sTmp values:-

sId = "1407900387";

    if ((3 == 13) && "")

{
  var sLinkLocation = sAddJavascriptEscapes('');

  sUrl = "OpenInformationItemLocation(\"" + sLinkLocation + "\", );";

}

else

  sUrl = "OpenHeaderLinkFromTable(\"http://172.220.1.4/QPR2014-1/Portal/QPR.Isapi.dll?PGPLUGIN&*24&SES=mWh8OHy43bW3LC5kC9yM-A&FMT=p&SKIN=portal&LAN=en%2c1&MODELID=1470448858&OBJECTID=1407900387\",\"http://172.220.1.4/QPR2014-1/Portal/QPR.Isapi.dll?PGPLUGIN&*24&SES=mWh8OHy43bW3LC5kC9yM-A&FMT=p&SKIN=portal&LAN=en%2c1&MODELID=1470448858&OBJECTID=1407900387\",\"" + sId + "\");";

window._sDefaultLink = window._sDefaultLink || sUrl;

RC("<table border='0' cellpadding='0' cellspacing='0'><tr><td><a id=\"a" + sId + "\" href='java<!-- no -->script:" + sUrl + "' title='" + sTmp + "'><img src='http://172.220.1.4/QPR2014-1/qprsoftware/pg/images/icn_subprocess.gif' title='" + sTmp2 + "'> " + sTmp + "<\/a>" + sTools + "</td></tr></table>", sTmp);

sTmp = "";

if (sTmp != "")

  sTmp = "<table border='0' cellspacing='0' cellpadding='0'>" + sDecodeURI(sTmp) + "</table>";

RC(sTmp, "");



html页面代码:-



Code of html page:-

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<script src="jquery.js"></script>
<script type="text/javascript">

function dataRet (d){
console.log(d);
}
function ajaxreq(){
debugger
 $.ajax({

url: *some link*
      error: function(jqxhr) {
          alert(jqxhr.responseText); // @text = response error, it is will be errors: 324, 500, 404 or anythings else
          },
      dataType:'html',
      success: function(data) {
           alert(data);
           console.log(data);
           var decoding = sDecodeURI(data);
           console.log(decoding);
      },

      type: 'post'
   })

function sDecodeURI(vsStr) 
{
debugger
  try {
    if (typeof(vsStr) !== "string")
      return vsStr;

    var slSplit = vsStr.split('%u');
    if (slSplit.length === 1)
      return decodeURIComponent(vsStr);

    var sResult = new StringBuilder(decodeURIComponent(slSplit[0]));
    for (var i = 1; i < slSplit.length; ++i) {
      var sTmp = slSplit[i];
      var len = sTmp.length;
      if (len < 4)
        sResult.append("%u" + sTmp);
      else {
        var charCode = sTmp.substr(0, 4);
        sResult.append(String.fromCharCode(parseInt(charCode,16)));
        sResult.append(decodeURIComponent(sTmp.substr(4, sTmp.length-4)));
      }
    }
    return sResult.toString();
  }
  catch (e) {
    // Fallback to old-style encoding
    return unescape(vsStr);
  }
} 
   ;
}

</script></head>
<body>
<input onclick="ajaxreq()" type="button" value="Click me to load info!"></input>
<div id="info"></div>
</body>
</html>



我尝试过的事情:

我尝试使用substring和indexOf调用数据,但是我没有获取值..



What I have tried:

I have tried to call the data using substring and indexOf but i don''t get the values..

推荐答案



我尝试过的事情:

我尝试使用substring和indexOf调用数据,但是我没有获取值..



What I have tried:

I have tried to call the data using substring and indexOf but i don''t get the values..


这篇关于如何在javascript中将元素值(sid和stmp值)作为键值对调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 10:42