how to assign values to var oop javascript from ajax request???
function getJSON(url) {
return $.ajax({
url: url,
type: 'get',
success: function(response){
response.w_v;
}
});
}
function Person(){
this.name = getJSON('proprieta_vetrina.php');
console.log(this.name);
}
const obj = new Person();
console.log(obj.name);
it's work!! <-- link code --> is my modification ok but i need call the object ouside the function is possible this??
function Person(valor){
this.name = valor
alert(this.name);
}
function test(url){
$.ajax({
url: url,
type: 'get',
success: function(response){
var valor = response.w_v;
const obj = new Person(valor);
},
error: function(e){
alert("error");
}
});
}
test('https://next.json-generator.com/api/json/get/4kqyRw--d');
how to do this:
const obj = new Person();
alert(obj.name); how do this ????
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.