小编Mid*_*hew的帖子

使用javascript将HTML页面中的div下载为pdf

我有一个id为"content"的内容div.在内容div中我有一些图表和一些表格.我想在用户点击下载按钮时将该div下载为pdf.有没有办法使用javascript或jQuery?

javascript jquery

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

将数据从前端插入到angularjs中的mysql数据库

我试图使用angularjs将数据从前端插入到mysql数据库.但即使没有错误消息,它也没有插入数据库.以下是我使用的代码.

的index.html

<html ng-app="demoApp">
   <head>
        <title> AngularJS Sample</title>
        <script src="js/angular.min.js"></script>
        <script src="js/angular-route.min.js"></script>
        <script type="text/javascript" src="js/script.js"></script>
    </head>
    <body>
        <div class="container" ng-view>
        </div>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

的script.js

    demoApp.config( function ($routeProvider,$locationProvider) {
    $routeProvider
        .when('/',
        {
            controller: 'SimpleController',
            templateUrl: 'Partials/view1.html'
        })
        .when('/view2',
        {
            controller: 'SimpleController',
            templateUrl: 'Partials/view2.html'
        })
        .otherwise({redirectTo: '/'});
    });
    demoApp.controller('SimpleController',function ($scope,$http){
    $http.post('server/view.php').success(function(data){
        $scope.friends = data;
    });;
    $scope.addNewFriend = function(add){
        var data = {
            fname:$scope.newFriend.fname,
            lname:$scope.newFriend.lname
        }
        $http.post("server/insert.php",data).success(function(data, status, headers, config){
            console.log("inserted Successfully");
        });
        $scope.friends.push(data);
        $scope.newFriend = {
            fname:"",
            lname:""
        };
    }; …
Run Code Online (Sandbox Code Playgroud)

javascript php mysql angularjs

15
推荐指数
1
解决办法
5万
查看次数

jQuery在控制台中工作但不是在原始代码中工作

我尝试了以下代码将href添加到td中的a标记.我在控制台做的很好.但是当我在我的代码中尝试相同时它不起作用.谁能告诉我原因?

<script>
    $("table tbody tr td a").attr('href','http://www.google.com');
 </script>
<table>
    <tr>
        <td><a >Hai</a></td>
    </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

jquery

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

为什么cant Dollar符号可以用作Wordpress中jQuery的替代品?

如果在wordpress中使用jQuery,为什么我们不能使用"$"?通常"$"是jQuery的替代品吗?但在Wordpress中它显示"$"不是一个功能.我不知道为什么会这样.谁能解释一下?

wordpress

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

TCPDF错误:无法包含字体定义文件:calibri

当我尝试使用html2pdf时出现错误:"TCPDF ERROR: Could not include font definition file: calibri"...

如何解决这个问题?

tcpdf html2pdf

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

自定义 JsonSchemaValidation 错误消息

我正在使用 Json 架构来验证 json 对象。我正确地收到错误消息。但它看起来更像是开发人员友好的错误消息。有什么方法可以自定义错误消息,以便我可以使其更加用户友好。我浏览了很多论坛,但没有找到解决方案。

下面是我使用的代码:

        string Json = @"{'Sheet1':[{'Location':'#$','First Name':11,'Last Name':'AAAAAAAAAAAAAAAAAAAAAAAAAAAAA','Amount':'A','Date of Birth':'8522/85/25'}]}";
        string JSONSchemaValidator = @"{'$schema':'http://json-schema.org/draft-04/schema#','title':'JSON Validation Schema','type':'object','additionalProperties':true,'properties':{'Sheet1':{'type':'array','items':{'type':'object','additionalProperties':true,'properties':{'Location':{'type':['number','string','null'],'pattern':'^[a-zA-Z0-9\\-\\s]+$','maxLength':15},'First Name':{'type':['string','null'],'maxLength':20,'pattern':'^[a-zA-Z\\-\\s]+$'},'Last Name':{'type':['string','null'],'maxLength':10,'pattern':'^[a-zA-Z\\-\\s]+$'},'Amount':{'type':['number','null'],'minimum':-999999999.99,'maximum':999999999.99,'exclusiveMaximum':true,'multipleOf':0.01},'Date of Birth':{'type':['string','null'],'format':'date-time'}}}}}}";
        JSchema schema = JSchema.Parse(JSONSchemaValidator);
        JObject person = JObject.Parse(Json);
        IList<string> iJSONSchemaValidatorErrorList;
        bool valid = person.IsValid(schema, out iJSONSchemaValidatorErrorList);

        if (iJSONSchemaValidatorErrorList != null && iJSONSchemaValidatorErrorList.Count > 0)
        {
            foreach (string error in iJSONSchemaValidatorErrorList)
            {
                Console.WriteLine(error);
            }
        }
        Console.ReadKey();
Run Code Online (Sandbox Code Playgroud)

以下是我收到的错误消息:

1. String '#$' does not match regex pattern '^[a-zA-Z0-9\-\s]+$'. Path 'Sheet1[0].Location', line 1, position 27.
2. Invalid type. Expected String, …
Run Code Online (Sandbox Code Playgroud)

c# json jsonschema json-schema-validator

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

不是DateTime格式的日期时间格式的字符串

我有一个不是日期时间格式的字符串,例如:20160503.如何将其更改为Datetime.我尝试使用Substring.它正在运作.有更有效的方法吗?以下是我现在所拥有的.

string a = "20160503";
int b = Convert.ToInt32(a.Substring(0, 4));
int c = Convert.ToInt32(a.Substring(4, 2));
int d = Convert.ToInt32(a.Substring(6, 2));
string date = b + "/" + c + "/" + d;
DateTime result = new DateTime();
DateTime.TryParse(date, out result);
Run Code Online (Sandbox Code Playgroud)

c# string datetime type-conversion

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

将默认时间设置为mobiscroll时间选择器

timepicker单击输入类型文本时,我使用以下代码显示.有没有办法设置default value这样01:00time picker??

$.plugin($afterSubPageLoad,{
end_time_picker:function()
{
    $(function(){$('#actualHours').scroller({preset: 'time',theme: 'wp',display: 'modal',mode: 'mixed',timeFormat:'HH:ii',timeWheels:'HHii'});});       
}
});
Run Code Online (Sandbox Code Playgroud)

javascript jquery mobiscroll

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

仅在子菜单悬停时显示子菜单的子菜单

我正在尝试显示将鼠标悬停在菜单上的子菜单。我已经成功完成了子菜单1级,但是当我进入子菜单2级(即子菜单的子菜单)时,它不起作用。我只想将鼠标悬停在1级子菜单上来显示2级子菜单。以下是我尝试过的代码

<ul class="nav">
    <li><a href="#">Home</a>
    </li>
    <li><a href="#">About Us</a>
        <ul class="submenu">
            <li><a href="#">Capabilities</a></li>
            <li><a href="#">Approach</a></li>
        </ul>
    </li>

    <li><a href="#">Careers</a>
        <ul class="submenu">
            <li><a href="#">Working With Us</a></li>
            <li><a href="#">Work Culture</a>
                <ul>
                    <li><a href="#">Benefits</a></li>
                </ul>
            </li>
        </ul>
    </li>
    <li><a href="#">Resources</a>
    </li>
    <li><a href="#">Contact Us</a>
    </li>
</ul>
Run Code Online (Sandbox Code Playgroud)

以下是jQuery

$('ul.submenu').hide();
$('ul.nav > li').hover(function () {
if ($(this).find('ul.submenu').length > 0) {
    $(this).find('ul.submenu').stop().slideDown('slow');
}
},function () {
    if ($(this).find('ul.submenu').length > 0) {
        $(this).find('ul.submenu').stop().slideUp('slow');
    }
});
Run Code Online (Sandbox Code Playgroud)

请在这里找到小提琴:http : //jsfiddle.net/Midhun28/RbY83/1/

html jquery

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

JSON.NET 中的 Linq

我有一个 json 字符串,如下所示

{
    'Sheet1': [{
        'EmployeeNo': '123456',
        'EmployeeName': 'Midhun Mathew'
    }, {
        'EmployeeNo': '123457',
        'EmployeeName': 'Bill Gates'
    }, {
        'EmployeeNo': '123456',
        'Address': 'AAAA'
    }, {
        'EmployeeNo': '123457',
        'Address': 'BBBB'
    }]
}
JObject parsedJson = JObject.Parse(jsonString);

// Get the EmployeeNo's 

List<JToken> tokenList = parsedJson["Sheet1"]
                           .GroupBy(d => d["EmployeeNo"])
                           .Select(s => s.Key)
                           .ToList();

// Get the tokens which have the Same 'EmployeeNo'

foreach (JToken j in tokenList)
{
    IEnumerable<JToken> t = parsedJson["Sheet1"].Where(s => s["EmployeeNo"] == j);
}
Run Code Online (Sandbox Code Playgroud)

但在 foreach 中我只得到第一个

{
  "EmployeeNo": …
Run Code Online (Sandbox Code Playgroud)

c# linq json json.net

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