最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery :cant use split function - Stack Overflow

programmeradmin6浏览0评论

I am using jQuery autoplete pluggin .

I have the following code

$().ready(function() {

    function findValueCallback(event, data, formatted) {
        $("<li>").html( !data ? "No match!" : "Selected: " + formatted)
            .appendTo("#result");
    }

});

I am trying to split the value ing in data.When i alert it,It is showing properly.But i cant use a split method to extract some data from it .(the data is "ASP.ASPItems.23" , I want to take that 23 from it

When i use split,I am getting an error like "split is undefined"

My split code

var subjectId=data.split(".")[2]

CAn any one advice how to go ahead

I am using jQuery autoplete pluggin .

I have the following code

$().ready(function() {

    function findValueCallback(event, data, formatted) {
        $("<li>").html( !data ? "No match!" : "Selected: " + formatted)
            .appendTo("#result");
    }

});

I am trying to split the value ing in data.When i alert it,It is showing properly.But i cant use a split method to extract some data from it .(the data is "ASP.ASPItems.23" , I want to take that 23 from it

When i use split,I am getting an error like "split is undefined"

My split code

var subjectId=data.split(".")[2]

CAn any one advice how to go ahead

Share Improve this question edited Aug 6, 2014 at 8:27 samjudson 56.9k7 gold badges60 silver badges69 bronze badges asked Jun 11, 2009 at 9:46 ShyjuShyju 219k106 gold badges419 silver badges498 bronze badges 1
  • Most likely data is not a string. What is typeof(data) ? – Blixt Commented Jun 11, 2009 at 9:49
Add a ment  | 

2 Answers 2

Reset to default 14

Well seeing as split is a method defined on a string, have you considered trying data.toString().split(".") or String(data).split(".") ?

var values = $("input[name='campstarttime\\[\\]']").map(function(){return $(this).val();}).get();

var result = values.toString().split(",") ;

alert(result[1]);
发布评论

评论列表(0)

  1. 暂无评论