Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
144373 | May 2,2019 09:07 PM UTC | May 6,2019 05:38 AM UTC | JavaScript - EJ 2 | 3 |
![]() |
Tags: DropDownList |
<div class="container">
<input type=text id="test" name="test"/>
<script language="JavaScript">
$( document ).ready(function() {
$.ajax({url: "getDDValues.php?action=getStatuses", success: function(result){
alert("Here");
var dat = JSON.stringify(result);
alert(dat);
//The alert shows the data below
//dat = [{"value":"NEW","text":"NEW"},{"value":"Accepted","text":"Accepted"}];
$("#test").ejDropDownList({dataSource:dat,fields: { text: "text", value: "value" }});
}});
});
</script>
</div>
When I get the json data from the url, it is identical to the dat variable commented out. I get an error:
Uncaught TypeError: Cannot read property 'slice' of undefined at Object._getFilteredList (ej.web.all.min.js:10) at Object._showFullList (ej.web.all.min.js:10) at Object._render (ej.web.all.min.js:10) at Object._init (ej.web.all.min.js:10) at new <anonymous> (ej.web.all.min.js:10) at w.fn.init.n.fn.(anonymous function) [as ejDropDownList] (http://{mysite}/EJ/Scripts/web/ej.web.all.min.js:10:24083) at Object.success (test1.php:69) at u (jquery-3.3.1.min.js:2) at Object.fireWith [as resolveWith] (jquery-3.3.1.min.js:2) at k (jquery-3.3.1.min.js:2) _getFilteredList @ ej.web.all.min.js:10 _showFullList @ ej.web.all.min.js:10 _render @ ej.web.all.min.js:10 _init @ ej.web.all.min.js:10 (anonymous) @ ej.web.all.min.js:10 n.fn.(anonymous function) @ ej.web.all.min.js:10 success @ test1.php:69 u @ jquery-3.3.1.min.js:2 fireWith @ jquery-3.3.1.min.js:2 k @ jquery-3.3.1.min.js:2 (anonymous) @ jquery-3.3.1.min.js:2 load (async) send @ jquery-3.3.1.min.js:2 ajax @ jquery-3.3.1.min.js:2 (anonymous) @ test1.php:64 l @ jquery-3.3.1.min.js:2 c @ jquery-3.3.1.min.js:2 setTimeout (async) (anonymous) @ jquery-3.3.1.min.js:2 u @ jquery-3.3.1.min.js:2 fireWith @ jquery-3.3.1.min.js:2 fire @ jquery-3.3.1.min.js:2 u @ jquery-3.3.1.min.js:2 fireWith @ jquery-3.3.1.min.js:2 ready @ jquery-3.3.1.min.js:2 _ @ jquery-3.3.1.min.js:2
When I uncomment the dat variable it works fine.
Can you please help me fill the list from the URL
Thanks,
JK
|
<script language="JavaScript">
$( document ).ready(function() {
$.ajax({url: 'https://services.odata.org/V4/Northwind/Northwind.svc/Customers', success: function(result){
var dat = result.value;
console.log(dat);
//The alert shows the data below
//dat = [{"value":"NEW","text":"NEW"},{"value":"Accepted","text":"Accepted"}];
$("#test").ejDropDownList({dataSource:dat,fields: { text: "CustomerID", value: "CompanyName" }});
}});
});
</script> |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.