如何在不使用视图的情况下返回ajax数据?

huangapple go评论42阅读模式
英文:

FW/1 How to return ajax data without view?

问题

我有以下的函数,它返回rc.employee。我从模型的索引页面调用这个函数checkempid。我是在onblur时触发它运行。我只想要数据返回,但是FW1似乎在我的div内再次渲染整个页面。如何只返回数据而不是整个页面/视图?

public any function checkempid(struct rc = {}) {
    var employeeid = rc.employeeid;
    rc.employee = variables.activeidentificationService.checkempid(employeeid);
}
英文:

I have the following function that returns rc.employee. I am calling this function checkempid from the index page of a model. I am triggering this to run onblur. I only want the data to come back, but FW1 seems to be rendering the entire page again inside my div. How can I only return the data and not the entire page/view?

public any function checkempid(struct rc = {}) {
	var employeeid = rc.employeeid;
	rc.employee = variables.activeidentificationService.checkempid(employeeid);
	
}	

答案1

得分: 1

我建议使用发送JSON响应,并使用这里的答案。

在您的情况下,因为您没有返回纯文本,您可以使用以下方式。

public any function checkempid(struct rc = {}) {
    var employeeid = rc.employeeid;
    rc.employee = variables.activeidentificationService.checkempid(employeeid);
    variables.fw.renderData("text", rc.employee);
}
英文:

I would suggest using sending a JSON response and use the answer here.

In your case since you are not returning a plain text you can use the following.

public any function checkempid(struct rc = {}) {
    var employeeid = rc.employeeid;
    rc.employee = variables.activeidentificationService.checkempid(employeeid);
    variables.fw.renderData( "text", rc.employee);
}

huangapple
  • 本文由 发表于 2023年6月1日 02:08:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76376245.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定