顯示回調輸出中的某些數據(需要jquery解決方案) - Display certain data in output from call back (jquery solution needed) -开发者知识库

顯示回調輸出中的某些數據(需要jquery解決方案) - Display certain data in output from call back (jquery solution needed) -开发者知识库,第1张

I am using a html web form to pass input fields to a php file using an AJax, the php file processes the data and returns data back. The data comes back as raw text but does have structure to it. However, alot of it i prefer not to display.

我使用一個html Web表單使用AJax將輸入字段傳遞給php文件,php文件處理數據並返回數據。數據以原始文本形式返回,但確實具有結構。但是,很多我不喜歡顯示。

How can I manipulate data to only show certain information.

如何操作數據以僅顯示某些信息。

For example, data returned may look like this:

例如,返回的數據可能如下所示:

[CN] => www.domain.com

[CN] => www.domain.com

[O] => ACME INC

[O] => ACME INC

Usually, the information returned is formatted like the above. Is there a way for me to do a search for, say [CN] and return the rest of the data om that same line excluding the characters =>

通常,返回的信息格式如上。有沒有辦法讓我進行搜索,比如[CN]並返回除了字符之外的同一行的其余數據=>

I should end up with only www.domain.com

我最終只能訪問www.domain.com

-- Sample of Ajax call --

- Ajax調用示例 -

$.ajax({
 url: 'test.php',
 success: function(response) {
 $('result').html(response);

2 个解决方案

#1


1  

One way to do it in JavaScript would be using a regular expression

在JavaScript中執行此操作的一種方法是使用正則表達式

var ajaxResponse = "\r\n[CN] => www.domain.com\r\n\r\n[O] => ACME INC\r\n";
var regexParser = /^\[CN]\s*=>\s*(.*)$/m;
var parseResult = regexParser.exec(ajaxResponse);
alert(parseResult[1]);

最佳答案:

本文经用户投稿或网站收集转载,如有侵权请联系本站。

发表评论

0条回复