jquery search in json

Solutions on MaxInterview for jquery search in json by the best coders in the world

showing results for - "jquery search in json"
Laura
02 Mar 2018
1$(function() {
2    var json = {
3        "people": {
4            "person": [{
5                "name": "Peter",
6                "age": 43,
7                "sex": "male"},
8            {
9                "name": "Zara",
10                "age": 65,
11                "sex": "female"}]
12        }
13    };
14    $.each(json.people.person, function(i, v) {
15        if (v.name.search(new RegExp(/peter/i)) != -1) {
16            alert(v.age);
17            return;
18        }
19    });
20});
21
Helena
17 Aug 2020
1<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.js"></script>
2    <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
3    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
4    <script type="text/javascript">
5        function process() {
6        	$.getJSON("http://www.mysite.com/json1.json"){
7        		$each(function(key,val){
8        			if ($("#text1").val()="thefirstname" && key="first"){
9	        	            $("#firstname").val(key.first);
10		                    $("#lastname").val(key.last);
11		                    $("#description").val(key.desc);
12			         }
13			});
14	      	});
15        }
16    </script>
17      <form name="myform" action="jQueryJson.htm">
18	    <input type="text" name="text1" value="thefirstname" size="30" />                    <tr><td align="center" colspan="3">
19<input type="button" name="search" value="Search for FirstName" size="50" onclick="process" /></td><td align="center"></td><td align="center">
20</td></tr>
21<input type="text" name="firstname" value="" size="4"/></td><td align="center">
22<input type="text" name="lastname" value="" size="4"/></td><td align="center">
23<input type="text" name="description" value="" size="4"/>
24	</form>
Izzie
10 Jul 2018
1<!DOCTYPE html>
2<html>
3<head>
4<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
5<script>
6$(document).ready(function(){
7    $("button").click(function(){
8        $.getJSON("json1.json", function(result){
9            $.each(result, function(i, obj){
10                $("div").append(obj.first + " " + obj.last + " " + obj.desc + " " + "<br>");
11            });
12        });
13    });
14});
15</script>
16</head>
17<body>
18
19<button>Get JSON data</button>
20
21<div></div>
22
23</body>
24</html>