In the following AJAX Function I need to assign the JSON to be response after the "success: function (data) {" statement. But I do not know how to do that. So is there anyone who can help me to solve this matter?
<pre lang="Javascript">
function setJsonSer(){
$.ajax({
url: "/APIWebService.asmx/AnalyticsDataShowWithPost",
type: 'POST',
data:{Email:'clientlink@russell.com',Password:'russell1234',URL:getVaria()},
success: function (data) {
var sTitle = $(data).find('string').text();
alert("sTitle Alert "+ sTitle);
alert("The data string " + data);
},
error: function (xhr, textStatus, errorThrown) {
alert('error in simple method');
alert(textStatus);
alert(errorThrown);
}
});
$.ajax({
url: "/APIWebService.asmx/GetMessage",
type: 'POST',
data:{Email:'clientlink@russell.com',Password:'russell1234',URL:getVaria()},
success: function (data) {
alert(success);
var sTitle = $(data).find('string').text();
alert(sTitle);
alert(data);
},
error: function (xhr, textStatus, errorThrown) {
alert('error in simple method');
alert(textStatus);
alert(errorThrown);
}
});
}
This getVaria() function is in an external JavaScript file.
function retStartDate(){
var strStartDate = document.getElementById("from_date").value;
return strStartDate;
}
function retEndDate(){
var strEndDate = document.getElementById("to_date").value;
return strEndDate;
}
function getVaria(){
var strWsUrl = 'https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A76546294& dimensions=ga%3Asource&metrics=ga%3Ausers&filters=ga%3Asource!%3D(direct)&sort=-ga%3Ausers&start-date= ' + retStartDate() + ' &end-date= ' + retEndDate() + ' &max-results=10';
alert("Chart 1 query is "+ strWsUrl);
return strWsUrl;
}
This var strWsUrl is the URL of the query for the chart.
Thanks & regards,
Chiranthaka