Fetch MyQL Data into the Jvector Map Using JSONSafely turning a JSON string into an objectSerializing to JSON in jQueryShould I use the datetime or timestamp data type in MySQL?Convert form data to JavaScript object with jQueryWhy does Google prepend while(1); to their JSON responses?How can I pretty-print JSON using JavaScript?Parse JSON in JavaScript?How does data binding work in AngularJS?The “right” JSON date formatFetch: POST json data

How can I maintain game balance while allowing my player to craft genuinely useful items?

If the mass of the Earth is decreasing by sending debris in space, does its angular momentum also decrease?

How did the European Union reach the figure of 3% as a maximum allowed deficit?

Are there any individual aliens that have gained superpowers in the Marvel universe?

How can I ping multiple IP addresses at the same time?

Basic power tool set for Home repair and simple projects

How to avoid offending original culture when making conculture inspired from original

Digital signature that is only verifiable by one specific person

I wish, I yearn, for an answer to this riddle

How "fast" do astronomical events occur?

Are there foreign customs agents on US soil?

How much steel armor can you wear and still be able to swim?

Simplify, equivalent for (p ∨ ¬q) ∧ (¬p ∨ ¬q)

First occurrence in the Sixers sequence

What kind of chart is this?

Bash function: Execute $@ command with each argument in sequence executed separately

What are the mechanical differences between Adapt and Monstrosity?

Got a new frameset, don't know why I need this split ring collar?

Does cooling a potato change the nature of its carbohydrates?

How to make all magic-casting innate, but still rare?

What is "dot" sign in •NO?

My student in one course asks for paid tutoring in another course. Appropriate?

Would a 7805 5v regulator drain a 9v battery?

How to recover a single blank shot from a film camera



Fetch MyQL Data into the Jvector Map Using JSON


Safely turning a JSON string into an objectSerializing to JSON in jQueryShould I use the datetime or timestamp data type in MySQL?Convert form data to JavaScript object with jQueryWhy does Google prepend while(1); to their JSON responses?How can I pretty-print JSON using JavaScript?Parse JSON in JavaScript?How does data binding work in AngularJS?The “right” JSON date formatFetch: POST json data






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have fetched values From my MySQL Database and stored it in JSON Format. Now What I am trying to do is that I need to show those values on the JvectorMap.
but I am not able to do it.



Here is my PHP code :



$json_data=array(); 

foreach($result as $rec)

$json_array['Country']=$rec['user_country'];
$json_array['CountryCode']=$rec['country_code'];
$json_array['persons']=$rec['usercountry'];

array_push($json_data,$json_array);
echo json_encode($json_data) ;


The JSON That I am recieving is :



[
"Country":"Australia","CountryCode":"AU","persons":"5",
"Country":"Spain","CountryCode":"ES","persons":"2",
"Country":"India","CountryCode":"IN","persons":"8",
"Country":"Mexico","CountryCode":"MX","persons":"4",
"Country":"United States","CountryCode":"US","persons":"4"
]


The Script that I am using is :



<script type="text/javascript">
var dataC = '<?php echo $data ; ?>' ;
var countryData = ;
$.each(dataC, function()
countryData[this.CountryCode] = this.persons;
);

$(function()
$('#world-map').vectorMap(
map: 'world_mill_en',
series:
regions: [
values: countryData, //load the data
scale: ['#C8EEFF', '#0071A4'],
normalizeFunction: 'polynomial']
,
//-----------------------------------------------
// changed to onRegionLabelShow from onLabelShow
//-----------------------------------------------
onRegionLabelShow: function(e, el, code)
//search through dataC to find the selected country by it's code
var country =$.grep(dataC, function(obj, index)
return obj.CountryCode == code;
)[0]; //snag the first one
//only if selected country was found in dataC
if (country != undefined)
el.html(el.html() +
"<br/><b>Code: </b>" +country.CountryCode +
"<br/><b>Name: </b>" + country.Country +
"<br/><b>persons: </b>" + country.persons);


);
);​
</script>


But I am getting the error :




" jquery.min.js:2 Uncaught TypeError: Cannot use 'in' operator to search for 'length' in ["Country":"Australia","CountryCode":"AU","persons":"5","Country":"Spain","CountryCode":"ES","persons":"2","Country":"India","CountryCode":"IN","persons":"8","Country":"Mexico","CountryCode":"MX","persons":"4","Country":"United States","CountryCode":"US","persons":"4"] "











share|improve this question
























  • there've been no characters. this code is really bothering me now. is there any other method ?

    – Abnit Chauhan
    Mar 25 at 6:42











  • As a matter of fact , there was a space in my Code. thanks for mentioning that. I removed the spaces but the main problem now I am facing is that how can I fetch the values in dataC object from php myql data

    – Abnit Chauhan
    Mar 25 at 7:20












  • I have updated the questions with the current Error : please have a look. @JaromandaX

    – Abnit Chauhan
    Mar 25 at 7:31











  • Please have a look into the issue @JaromandaX

    – Abnit Chauhan
    Mar 25 at 10:49

















0















I have fetched values From my MySQL Database and stored it in JSON Format. Now What I am trying to do is that I need to show those values on the JvectorMap.
but I am not able to do it.



Here is my PHP code :



$json_data=array(); 

foreach($result as $rec)

$json_array['Country']=$rec['user_country'];
$json_array['CountryCode']=$rec['country_code'];
$json_array['persons']=$rec['usercountry'];

array_push($json_data,$json_array);
echo json_encode($json_data) ;


The JSON That I am recieving is :



[
"Country":"Australia","CountryCode":"AU","persons":"5",
"Country":"Spain","CountryCode":"ES","persons":"2",
"Country":"India","CountryCode":"IN","persons":"8",
"Country":"Mexico","CountryCode":"MX","persons":"4",
"Country":"United States","CountryCode":"US","persons":"4"
]


The Script that I am using is :



<script type="text/javascript">
var dataC = '<?php echo $data ; ?>' ;
var countryData = ;
$.each(dataC, function()
countryData[this.CountryCode] = this.persons;
);

$(function()
$('#world-map').vectorMap(
map: 'world_mill_en',
series:
regions: [
values: countryData, //load the data
scale: ['#C8EEFF', '#0071A4'],
normalizeFunction: 'polynomial']
,
//-----------------------------------------------
// changed to onRegionLabelShow from onLabelShow
//-----------------------------------------------
onRegionLabelShow: function(e, el, code)
//search through dataC to find the selected country by it's code
var country =$.grep(dataC, function(obj, index)
return obj.CountryCode == code;
)[0]; //snag the first one
//only if selected country was found in dataC
if (country != undefined)
el.html(el.html() +
"<br/><b>Code: </b>" +country.CountryCode +
"<br/><b>Name: </b>" + country.Country +
"<br/><b>persons: </b>" + country.persons);


);
);​
</script>


But I am getting the error :




" jquery.min.js:2 Uncaught TypeError: Cannot use 'in' operator to search for 'length' in ["Country":"Australia","CountryCode":"AU","persons":"5","Country":"Spain","CountryCode":"ES","persons":"2","Country":"India","CountryCode":"IN","persons":"8","Country":"Mexico","CountryCode":"MX","persons":"4","Country":"United States","CountryCode":"US","persons":"4"] "











share|improve this question
























  • there've been no characters. this code is really bothering me now. is there any other method ?

    – Abnit Chauhan
    Mar 25 at 6:42











  • As a matter of fact , there was a space in my Code. thanks for mentioning that. I removed the spaces but the main problem now I am facing is that how can I fetch the values in dataC object from php myql data

    – Abnit Chauhan
    Mar 25 at 7:20












  • I have updated the questions with the current Error : please have a look. @JaromandaX

    – Abnit Chauhan
    Mar 25 at 7:31











  • Please have a look into the issue @JaromandaX

    – Abnit Chauhan
    Mar 25 at 10:49













0












0








0








I have fetched values From my MySQL Database and stored it in JSON Format. Now What I am trying to do is that I need to show those values on the JvectorMap.
but I am not able to do it.



Here is my PHP code :



$json_data=array(); 

foreach($result as $rec)

$json_array['Country']=$rec['user_country'];
$json_array['CountryCode']=$rec['country_code'];
$json_array['persons']=$rec['usercountry'];

array_push($json_data,$json_array);
echo json_encode($json_data) ;


The JSON That I am recieving is :



[
"Country":"Australia","CountryCode":"AU","persons":"5",
"Country":"Spain","CountryCode":"ES","persons":"2",
"Country":"India","CountryCode":"IN","persons":"8",
"Country":"Mexico","CountryCode":"MX","persons":"4",
"Country":"United States","CountryCode":"US","persons":"4"
]


The Script that I am using is :



<script type="text/javascript">
var dataC = '<?php echo $data ; ?>' ;
var countryData = ;
$.each(dataC, function()
countryData[this.CountryCode] = this.persons;
);

$(function()
$('#world-map').vectorMap(
map: 'world_mill_en',
series:
regions: [
values: countryData, //load the data
scale: ['#C8EEFF', '#0071A4'],
normalizeFunction: 'polynomial']
,
//-----------------------------------------------
// changed to onRegionLabelShow from onLabelShow
//-----------------------------------------------
onRegionLabelShow: function(e, el, code)
//search through dataC to find the selected country by it's code
var country =$.grep(dataC, function(obj, index)
return obj.CountryCode == code;
)[0]; //snag the first one
//only if selected country was found in dataC
if (country != undefined)
el.html(el.html() +
"<br/><b>Code: </b>" +country.CountryCode +
"<br/><b>Name: </b>" + country.Country +
"<br/><b>persons: </b>" + country.persons);


);
);​
</script>


But I am getting the error :




" jquery.min.js:2 Uncaught TypeError: Cannot use 'in' operator to search for 'length' in ["Country":"Australia","CountryCode":"AU","persons":"5","Country":"Spain","CountryCode":"ES","persons":"2","Country":"India","CountryCode":"IN","persons":"8","Country":"Mexico","CountryCode":"MX","persons":"4","Country":"United States","CountryCode":"US","persons":"4"] "











share|improve this question
















I have fetched values From my MySQL Database and stored it in JSON Format. Now What I am trying to do is that I need to show those values on the JvectorMap.
but I am not able to do it.



Here is my PHP code :



$json_data=array(); 

foreach($result as $rec)

$json_array['Country']=$rec['user_country'];
$json_array['CountryCode']=$rec['country_code'];
$json_array['persons']=$rec['usercountry'];

array_push($json_data,$json_array);
echo json_encode($json_data) ;


The JSON That I am recieving is :



[
"Country":"Australia","CountryCode":"AU","persons":"5",
"Country":"Spain","CountryCode":"ES","persons":"2",
"Country":"India","CountryCode":"IN","persons":"8",
"Country":"Mexico","CountryCode":"MX","persons":"4",
"Country":"United States","CountryCode":"US","persons":"4"
]


The Script that I am using is :



<script type="text/javascript">
var dataC = '<?php echo $data ; ?>' ;
var countryData = ;
$.each(dataC, function()
countryData[this.CountryCode] = this.persons;
);

$(function()
$('#world-map').vectorMap(
map: 'world_mill_en',
series:
regions: [
values: countryData, //load the data
scale: ['#C8EEFF', '#0071A4'],
normalizeFunction: 'polynomial']
,
//-----------------------------------------------
// changed to onRegionLabelShow from onLabelShow
//-----------------------------------------------
onRegionLabelShow: function(e, el, code)
//search through dataC to find the selected country by it's code
var country =$.grep(dataC, function(obj, index)
return obj.CountryCode == code;
)[0]; //snag the first one
//only if selected country was found in dataC
if (country != undefined)
el.html(el.html() +
"<br/><b>Code: </b>" +country.CountryCode +
"<br/><b>Name: </b>" + country.Country +
"<br/><b>persons: </b>" + country.persons);


);
);​
</script>


But I am getting the error :




" jquery.min.js:2 Uncaught TypeError: Cannot use 'in' operator to search for 'length' in ["Country":"Australia","CountryCode":"AU","persons":"5","Country":"Spain","CountryCode":"ES","persons":"2","Country":"India","CountryCode":"IN","persons":"8","Country":"Mexico","CountryCode":"MX","persons":"4","Country":"United States","CountryCode":"US","persons":"4"] "








javascript php mysql jvectormap






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 7:30







Abnit Chauhan

















asked Mar 25 at 5:10









Abnit ChauhanAbnit Chauhan

4210




4210












  • there've been no characters. this code is really bothering me now. is there any other method ?

    – Abnit Chauhan
    Mar 25 at 6:42











  • As a matter of fact , there was a space in my Code. thanks for mentioning that. I removed the spaces but the main problem now I am facing is that how can I fetch the values in dataC object from php myql data

    – Abnit Chauhan
    Mar 25 at 7:20












  • I have updated the questions with the current Error : please have a look. @JaromandaX

    – Abnit Chauhan
    Mar 25 at 7:31











  • Please have a look into the issue @JaromandaX

    – Abnit Chauhan
    Mar 25 at 10:49

















  • there've been no characters. this code is really bothering me now. is there any other method ?

    – Abnit Chauhan
    Mar 25 at 6:42











  • As a matter of fact , there was a space in my Code. thanks for mentioning that. I removed the spaces but the main problem now I am facing is that how can I fetch the values in dataC object from php myql data

    – Abnit Chauhan
    Mar 25 at 7:20












  • I have updated the questions with the current Error : please have a look. @JaromandaX

    – Abnit Chauhan
    Mar 25 at 7:31











  • Please have a look into the issue @JaromandaX

    – Abnit Chauhan
    Mar 25 at 10:49
















there've been no characters. this code is really bothering me now. is there any other method ?

– Abnit Chauhan
Mar 25 at 6:42





there've been no characters. this code is really bothering me now. is there any other method ?

– Abnit Chauhan
Mar 25 at 6:42













As a matter of fact , there was a space in my Code. thanks for mentioning that. I removed the spaces but the main problem now I am facing is that how can I fetch the values in dataC object from php myql data

– Abnit Chauhan
Mar 25 at 7:20






As a matter of fact , there was a space in my Code. thanks for mentioning that. I removed the spaces but the main problem now I am facing is that how can I fetch the values in dataC object from php myql data

– Abnit Chauhan
Mar 25 at 7:20














I have updated the questions with the current Error : please have a look. @JaromandaX

– Abnit Chauhan
Mar 25 at 7:31





I have updated the questions with the current Error : please have a look. @JaromandaX

– Abnit Chauhan
Mar 25 at 7:31













Please have a look into the issue @JaromandaX

– Abnit Chauhan
Mar 25 at 10:49





Please have a look into the issue @JaromandaX

– Abnit Chauhan
Mar 25 at 10:49












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55331551%2ffetch-myql-data-into-the-jvector-map-using-json%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55331551%2ffetch-myql-data-into-the-jvector-map-using-json%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript