JSFiddle - React, Tailwind, and code Playground
by Yubraj Pokharel
HTML
<script src="https://code.jquery.com/jquery-3.2.1.js"></script>
<input type="text" name="city" id="agreementSearchText" list="cityname">
<datalist id="cityname">
<option value="Boston">
<option value="Cambridge">
</datalist>
JavaScript
function getServiceResponse(url, jsonObj, reqType, cacheFlag, callback) {
var strReturn = null;
if (url != '' && reqType != '') {
if (reqType == 'POST') {
$.ajax({
url: url,
type: 'POST',
data: (jsonObj),
cache: false,
global: false,
dataType: 'json',
async: false,
contentType: 'application/json; charset=UTF-8',
crossDomain: true,
headers: { Accept: 'application/json; charset=UTF-8' },
// error: function(jqXHR, textStatus, errorThrown) {alert(errorThrown);},
success: function(data) {
if (data == 'sessionTimeOut') {
document.location.href = '/insightweb/login';
} else if (callback != null) {
callback(data);
} else {
strReturn = data;
}
},
});
} else if (reqType == 'GET') {
$.ajax({
url: url,
type: 'GET',
dataType: 'json',
cache: false,
async: false,
contentType: 'application/json; charset=UTF-8',
crossDomain: true,
headers: { Accept: 'application/json; charset=UTF-8' },
// error: function(jqXHR, textStatus, errorThrown) {alert(errorThrown);},
...