What I need to do:
- I need to match Json with
string.
case 1: When industry data is set in Json
["", "app.php", "automotive", "tradeshows"]
JQuery code:
$( document ).ready(function()
{
var match = window.location.pathname.split("/");
console.log(match[3]);
if(match[3]=="conferences")
{
console.log("true");
$('#radio3').prop('checked', true);
}
else if(match[3]=="tradeshows")
{
console.log("afeef");
$('#radio2').prop('checked', true);
}
else
{
$('#radio1').prop('checked', true);
}
});
case 2: When industry data is not set in Json
["", "app.php", "tradeshows"]
In this case match would be failed.
Is there any other way in match Json with
stringin JQuery?I need to match the Json with
stringso is there any other way so that I could match Json withstring?
var match = window.location.pathname.split("/"); if(match.length < 4) {$('#radio1').prop('checked', true); return;} //rest of code.... But FYI, this has nothing to do with JSON but javascript array, JSON is an object notation