Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

似乎不能拦截jquery的 $.get()请求 #57

Closed
JailBreakC opened this issue Apr 14, 2015 · 1 comment
Closed

似乎不能拦截jquery的 $.get()请求 #57

JailBreakC opened this issue Apr 14, 2015 · 1 comment

Comments

@JailBreakC
Copy link

https://jsfiddle.net/BeENf/3/

// Mock.mock(rurl, template)
Mock.mock(/\.json/, {
    'list|1-10': [{
        'id|+1': 1,
        'email': '@EMAIL'
    }]
})
$.get('hello.json').done(function(data, status, jqXHR){
    $('<pre>').text(JSON.stringify(data, null, 4))
        .appendTo('body')
})
@nuysoft
Copy link
Owner

nuysoft commented Apr 17, 2015

需要指定 dataType: 'json'
Mock.js 只会拦截数据类型为 'json''jsonp' 的请求。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants