Javascript Web Widget [英] Javascript web Widget

查看:56
本文介绍了Javascript Web Widget的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


谁能告诉我如何构建一个Web部件(使用jQuery).以我的观点,通过ajax XMLHttpRequset从数据库中获取数据并以JSON格式获取responseText,而无需使用document.wrte()方法和将参数传递给js函数.即我想在整个项目中重用该javascript代码.

请任何人告诉我这种格式是对还是错.而且我无法以这种方式获得输出.

快速帮助表示赞赏.

Hi,
can anyone tell me How to build a web widget (using jQuery).in my point of view, get data from database through ajax XMLHttpRequset and get responseText in JSON format and display dynamically in webpage with out using document.wrte() method and with passing parameters to js functions. i.e i want to reuse that javascript code in whole project.

please can any one tell me whether this format is right or wrong. and i was unable to get output in this way.

quick help appreciated.

推荐答案

伪代码,因为我不知道jQuery如何格式化AJAX请求,但大致来说:

Pseudocode, because I don''t know how jQuery formats AJAX requests, but broadly:

function updateWidget(url){
 ajaxFramework.sendAjaxRequest(url, function(content){
  myDiv.innerHTML = content;
 });
}



(假设jQuery允许您发出AJAX请求并向其传递回调函数)

并且,在HTML



(assuming jQuery lets you make an AJAX request and pass it a callback function)

and, in the HTML

...
<div id=myDiv class=whatever> ... </div>


您可以使用


.jquery的ajax方法

使用thing方法,您可以从服务器端获取json,html数据.您可以在此处
.ajax method of jquery

using thing method you can get json, html data from server side. you can fine more details here


这篇关于Javascript Web Widget的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆