Ask a regular:
The data is sometimes like this:
["Two S", "Li S", "Wang S", "one S"]
[{"DEVID": 1, "area": "Guangzhou", "USERID": null, "USERNAME": "King S", "Devtype": null, "Devname": "IPad2", "Devimei": " IPAD2346523985687 "," isusable ": 1," binddate ":" 2013-05-13t09:05:33 "," UPDATEUSER ": null," UpdateTime ":" 0001-01-01t00 : 00:00 "}]
Or
["Two S", "Li S", "Wang S", "one S"]
Or
[{"DEVID": 1, "area": "Guangzhou", "USERID": null, "USERNAME": "King S", "Devtype": null, "Devname": "IPad2", "Devimei": " IPAD2346523985687 "," isusable ": 1," binddate ":" 2013-05-13t09:05:33 "," UPDATEUSER ": null," UpdateTime ":" 0001-01-01t00 : 00:00 "}]
How do you judge in your code whether this character contains [?].
Success:function (returnvalue) { //select var returnjson = returnvalue.split (' [')] [0] + '] '; var returnValue1 = ' [' + returnvalue.split ('] [') [1];
This can sometimes be an error, I want to use a regular to determine the existence of the character [to intercept the data
Reply to discussion (solution)
IndexOf () method
Isn't that JSON? Why do you want a string intercept?
Isn't that JSON? Why do you want a string intercept?
["Two S", "Li S", "Wang S", "one S") This paragraph should be taken out separately put in the drop-down box
[{"DEVID": 1, "area": "Guangzhou", "USERID": null, "USERNAME": "King S", "Devtype": null, "Devname": "IPad2", "Devimei": " IPAD2346523985687 "," isusable ": 1," binddate ":" 2013-05-13t09:05:33 "," UPDATEUSER ": null," UpdateTime ":" 0001-01-01t00 : 00:00 "}]
This section is going to form a form
Sometimes there are 2 pieces of data, sometimes only the latter. So I want to determine if there are 2 pieces of data. How do you write it?
IndexOf () method
var str= "Hello world!" A value greater than 0, with 2 segments of data, is intercepted. Otherwise it is a piece of data, the direct assignment does not intercept. Is that what it means? if (Returnvalue.indexof ("[") > 0) { var Returnjson = Returnvalue.split ('] [') [0] + '] '; var returnValue1 = ' [' + returnvalue.split ('] [') [1]; else{ var returnvalue;}
IndexOf () method
I tested it this way, var = "[ReturnValue]" When it is OK, but var returnvalue = "[1]";