Unable to fetch json data

Unable to fetch json data from backend can anyone what’s the wrong in the code:

I have input box with id=“cnc-searchcriteria” after typing country name and clicking on button need to get the results.

`<button value="click" onclick="makeRequest()"></button>`
    function makeRequest() 
    {
    	
    	alert($('#cnc-searchcriteria').val());
    	var searchData=$('#cnc-searchcriteria').val();
    	
    	 $.ajax({
    	    url:"cnc/cncstorelocator",
    	    type:'GET',   
    	    data: {searchCriteria : $('#cnc-searchcriteria').val()},
    	    dataType: 'json',
    	    success : function(cncStoreLocatorData)
    		{
    	    	if (cncStoreLocatorData != null)
    	    		{
    	    			alert("Retieving stores");
    	    		}
    	    	var searchStore = JSON.stringify(cncStoreLocatorData);
    	    	/*console.log(searchStore);*/
    	    	
    	    	$.each(searchStore, function(i,item)
    		    		{
    		    		$("<div></div>").html("<h3>"+item.country+"</h3>").appendTo("div#cjsondata");
    		    		}); 
    	    	
    	    		//$('#cncjsondata').html(searchStore);
    	    		//var parsedJson = $.parseJSON(searchStore);
    	    		//alert(parsedJson);
    	    		//DisplayStores(parsedJson);
    			//MapResults(searchStore);
    		},
    	    error: function(cncStoreLocatorData) {
    	    	alert("can't make req");
    	    }
    	});  
    }

as far as the request is concerned, nothing looks off, but the dev tools will provide you with more inside that we can from this snippet.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.