I got the correct value for the country_id by changing the the following:
var country_id = e.target.value; to var country_id = $('select[name="country"]').val();
The area selection is not listing any data but this <option>Select an area</option>.
I got the following details from the Chrome's inspect:
Collection {#261
#items: array:2 [
0 => Area {#260
#fillable: array:3 [
0 => "area"
1 => "state_id"
2 => "country_id"
]
+timestamps: false
#connection: null
#table: null
#primaryKey: "id"
#perPage: 15
+incrementing: true
#attributes: array:2 [
"id" => 3
"name" => "Corvallis"
]
#original: array:2 [
"id" => 3
"name" => "Corvallis"
]
#relations: []
#hidden: []
#visible: []
#appends: []
#guarded: array:1 [
0 => "*"
]
#dates: []
#dateFormat: null
#casts: []
#touches: []
#observables: []
#with: []
#morphClass: null
+exists: true
+wasRecentlyCreated: false
}
1 => Area {#270
#fillable: array:3 [
0 => "area"
1 => "state_id"
2 => "country_id"
]
+timestamps: false
#connection: null
#table: null
#primaryKey: "id"
#perPage: 15
+incrementing: true
#attributes: array:2 [
"id" => 7
"name" => "Portland"
]
#original: array:2 [
"id" => 7
"name" => "Portland"
]
#relations: []
#hidden: []
#visible: []
#appends: []
#guarded: array:1 [
0 => "*"
]
#dates: []
#dateFormat: null
#casts: []
#touches: []
#observables: []
#with: []
#morphClass: null
+exists: true
+wasRecentlyCreated: false
}
]
}
It seems like it is showing the correct areas from the attributes, but just isn't displaying them out under the area selection. What did I do wrong?