小编fra*_*zon的帖子

clearInterval不起作用

我有一个div,它高于我想要展示的东西,我有setInterval工作,但是clearInterval当它到达2个循环时它不会被触发.

我有这个:

window.setInterval(play_ani_clickthese, 3000);
var fade_count = 0;

function play_ani_clickthese() {
    $("#click_these").fadeIn(1000).delay(1000).fadeOut(1000);
    fade_count += parseInt('1');

    if(fade_count == 2) window.clearInterval(play_ani_clickthese);
}
Run Code Online (Sandbox Code Playgroud)

但是当'fade_count'达到2时,它就会继续下去.

什么指向我做错了什么?

javascript

1
推荐指数
1
解决办法
4188
查看次数

重复调用setTimeout比在3秒的间隔之后调用

为什么重复调用函数比3秒后重复调用?

<button onclick="myFunction()">Try it</button>

<script>
    function myFunction()
    {
        alert("hello");
        setTimeout(myFunction(),3000);
        // setTimeout(function(){ alert("Hello") }, 3000);
     }
</script>
Run Code Online (Sandbox Code Playgroud)

javascript

0
推荐指数
1
解决办法
151
查看次数

使用Jquery将php字符串数据转换为Json对象

我需要从PHP到jquery获取一些Json数据.

我需要在javascript方法中使用以下格式.

function returnJson()
{
   return {
            events: [
            {
                "id": 1,
                "start": new Date(2013, 4, 26, 12),
                "end": new Date(2013, 4, 26, 13, 30),
                "title": "Lunch with Mike"
            },
            {
                "id": 2,
                "start": new Date(2013, 4, 27, 14),
                "end": new Date(2013,4, 27, 14, 45),
                "title": "Dev Meeting"
            }]
       };
}
Run Code Online (Sandbox Code Playgroud)

为此,我在javascript中执行以下操作:

function returnJson()
{
    var eventResult = $.getJSON("../PHP/PhpAction.php?f=fetchCalendarEvent");
    return eventResult;
}
Run Code Online (Sandbox Code Playgroud)

在PHP中:

 function fetchCalendarEvent()
          {
              $tablename = "tb_calendar";

              $sql = "SELECT eventId,userId,enentName,eventText,EXTRACT(YEAR FROM startTime) AS startyear,EXTRACT(MONTH FROM startTime) AS …
Run Code Online (Sandbox Code Playgroud)

javascript php jquery json

0
推荐指数
1
解决办法
2596
查看次数

Spring:使用@RequestBody的JSON到Java对象

我'与弹簧安置网络service.I'am无法工作转换JSON为Java Object使用@RequestBody.

控制器方法:

@RequestMapping(value="/test",method=RequestMethod.POST)
public @ResponseBody String test(@RequestBody Student s)
{

    System.out.print(s.getName()+s.getMark()+s.getRollNo());

    return "ok";
}
Run Code Online (Sandbox Code Playgroud)

POJO课程:

 public class Student implements Serializable {


private static final long serialVersionUID = 1L;
private int mark;
private String name;
private int rollNo;
    // getters and setters
  }
Run Code Online (Sandbox Code Playgroud)

Serlvet-context.xml中的MessageConverter:

    <beans:bean id="jacksonMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"></beans:bean>
 <beans:bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<beans:property name="messageConverters">
  <beans:list>
    <beans:ref bean="jacksonMessageConverter"/>
  </beans:list>
</beans:property>
</beans:bean>
Run Code Online (Sandbox Code Playgroud)

我正在使用POSTMANrest client chrome插件来调用webservice.JSON object传递的是:

{"mark":30,"name":"sam","rollNo":100}
Run Code Online (Sandbox Code Playgroud)

415 Unsupported Media Type在调用Web服务时得到了响应.

请帮忙.提前致谢!

jquery spring json web-services spring-mvc

0
推荐指数
1
解决办法
2218
查看次数

如何在moodle中创建自定义表单?

我想在moodle中创建一个自定义表单并将表单数据存储在数据库表中.我一直在研究moodle表库,但对我来说太复杂了.

有关如何在moodle中创建自定义表单以及将表单数据存储在数据库中的任何帮助或指导或教程或参考指南或电子书将非常感激.

moodle

0
推荐指数
2
解决办法
2万
查看次数

标签 统计

javascript ×3

jquery ×2

json ×2

moodle ×1

php ×1

spring ×1

spring-mvc ×1

web-services ×1