last day (14 days later) » 

15:13
0
Q: Unable get data inside $when $done

javapatriotOK, so Im trying to figure out why the same two pieces are not working. One works outside of my when/done statement but the one that i need to work is inside when/done. Can someone take a look and tell me what im doing wrong. Im able to get 2 out of 3 requests working just fine. jQuery(function(...

ajax is asynchronous - calling jQuery('.totalinv').append(totalcost);jQuery('.totalleads').append(totalcomplet‌​‌​ions);jQuery('.perleadvalue').append(perleadvalue); outside the done/success block will not get the expected results. totalcost is also never defined in the code above
Sorry, i updated the code to reflect the correct variables. Totalcost was replaced by totalinv and GoalValueTotals was replaced by GoalValueData
@javapatriot did you solve it? It's failing because you have mixed-content (http/https) which the browser is blocking
Thanks but im confused because it is not blocking it when i call it outside of when/done, why would it be blocking it there?
@ᾠῗᵲᄐᶌ don't know if you saw my last response but it works when i call it outside of when/done, why would it be blocking it there?
You are probably on https - so when you call jQuery.getJSON(NewConvData, function(data3) { it works because var NewConvData ='https but jQuery.when( jQuery.getJSON(WeatherAPI), jQuery.getJSON(goaltotal), jQuery.getJSON(NewConvData) is a mix of http/https
Just look at the protocol of your urls var NewConvData ='https://api.logmycalls.com'(https) - var goaltotal = 'http://dawsonselectric.com(http) - var WeatherAPI = 'http://api.worldweatheronline.com(http)
15:13
@ᾠῗᵲᄐᶌ, i updated the JS to have all files come from https protocols but i still get the same result. Take a look.
I just moved this conversation to chat, hope you dont mind
Nope I don't
Did you understand what I was talking about though?
yes, i had mixed content but even when i changed all of the links to https im still not getting the expected result
ultimately what im trying to do is pull data from the goaltotal and NewConvData and do calculations based on the data pulled
What browser are you using?
Firefox
In chrome it's because https://dawsonselectric.com/wp-content/plugins/CSAnalytics/lib/data/data-GoalVa‌​lueTotals.php is probably using a self-signed cert so you have to trust it first
Chrome is blocking because it doesn't trust the SSL cert
15:21
i changed that URL to aspentouch.com/wp-content/plugins/CSAnalytics/lib/data/…‌​lueT‌​otals.php
that was is on a trusted SSL
let me test again with the new url
no more ajax errors now
i just changed the goaltotal url to 'https://aspentouch.com/wp-content/plugins/CSAnalytics/lib/data/data-GoalValueTo‌​tals.php';
notice how the first table set did not load but the second did
the second one is outside of the when/done statement
the first one is inside
this table?
2015-12-01

62°

57°

Overcast

2015-12-02

69°

51°

Overcast

Goal Conversion Rate: 0.00%
Goal Completions: 0
Goal Value: $0.0
2015-12-03

53°

40°

Overcast

Goal Conversion Rate: 0.00%
Goal Completions: 0
Goal Value: $0.0
15:25
no, this one: #conv_table_one
15:37
you should be looping through data3[0]
so jQuery.each(data3[0].results
then it should be data3[0].results[i].calldate to get your data
The reason for that is because the data returned is [Object, Array[3], Array[3]]. So since data3 is an array you have to grab the object which is in the first index
16:24
Great that works. So i modified it some and im getting most of the expected results now (thanks to you.) Mind aiding me understanding why I cannot get his one thing to appear?
jsfiddle.net/javapatriot/v5r7xnjg/1 i'm trying to get compsumvalueall to display the sum of all goal completions in the array
data contains an array also - which your dataarray is actually in the 0 index.
jQuery.each(data[0], function(i,v){
compsumvalueall += parseFloat(v.goalCompletionsAll);
});
THANKS! Clearly im missing the fact that these are arrays, what can use/see to know that these are arrays
also just FYI inside the each function you can use the second argument instead of doing the index thing jQuery.each(data[0], function(index,value){.. where value=data[0][index]
I just do a console.log(data) - then look in the console and it showed that it's an array [Array[31], "success", Object]
in Chrome
Yup
I like chrome for it's debugging tools
Firefox is ok but I'm too used to chrome lol
16:37
i hear ya, i'm more of a FF guy but it looks like im going to have to start using Chrome more! A huge thank you!
NP :) Gonna go on a break
Cya

last day (14 days later) »