Timeline for PHP array to JavaScript array using json_encode()
Current License: CC BY-SA 3.0
11 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 8, 2017 at 0:23 | history | edited | Sᴀᴍ Onᴇᴌᴀ | CC BY-SA 3.0 |
update formatting, correct spelling
|
| Jun 8, 2017 at 0:20 | answer | added | Sᴀᴍ Onᴇᴌᴀ | timeline score: 0 | |
| Jun 4, 2017 at 6:08 | comment | added | Rasclatt | @Barmar I didn't know that, learn something new every day! | |
| Jun 4, 2017 at 6:05 | answer | added | Tom Udding | timeline score: 0 | |
| Jun 4, 2017 at 6:02 | comment | added | Barmar |
@Rasclatt The method: option was added in jQuery 1.9. It's equivalent to type:.
|
|
| Jun 4, 2017 at 5:35 | answer | added | Rasclatt | timeline score: 1 | |
| Jun 4, 2017 at 5:27 | comment | added | Rasclatt |
It might also be useful to send an action in the data and check for it in the file instead of just checking for a post, especially if you expand upon this script in the future: data:{"action":"get_name_city"}, then in the PHP it would look like if(isset($_POST['action']) && $_POST['action'] == 'get_name_city') { etc....
|
|
| Jun 4, 2017 at 5:22 | comment | added | Rasclatt |
Also it's not method:"POST" it's type:"POST", right now you are probably sending a $_GET
|
|
| Jun 4, 2017 at 5:21 | comment | added | Rasclatt |
You shouldn't be able to get data.name because you stored your associate arrays inside a standard array. Should be some thing like data[0].name because it would be in an object like [{"name":"something","city":something"},{"name":"some name","city":something else"}], try just console.log(data); see if that comes through as the object
|
|
| S Jun 4, 2017 at 5:14 | review | Triage | |||
| Jun 4, 2017 at 8:08 | |||||
| S Jun 4, 2017 at 5:14 | history | asked | Mason White | CC BY-SA 3.0 |