Click here to Skip to main content
15,844,498 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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">
JavaScript
function setJsonSer(){
 		$.ajax({
    			url: "/APIWebService.asmx/AnalyticsDataShowWithPost",
    			type: 'POST',

    		data:{Email:'clientlink@russell.com',Password:'russell1234',URL:getVaria()},

    			success: function (data) {
        		//alert("success alert    "+ data);
			//alert(JSON.stringify(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.

JavaScript
function retStartDate(){
   var strStartDate = document.getElementById("from_date").value;
   //alert("Start date " + strStartDate);
   return strStartDate;

   }

    function retEndDate(){
    var strEndDate = document.getElementById("to_date").value;
    //alert("End date " + strEndDate);
    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
Posted
Updated 24-Jul-14 22:06pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900