使用JQuery的ajax函数,我在javascript对象的尝试形式中获取数据,并希望将其用作全局变量以供将来使用。我的问题是,当我尝试将数据作为javascript对象接收时,它是无法访问的,但是当我将其作为纯文本返回时,它将返回并可用作字符串。我可以在开发人员选项中看到数据被返回并正确布局,但我仍然无法在控制台中使用它。
从获取字符串到拥有可用对象,我该怎么做?
的Perl
这些是我在脚本中使用的内容类型标题。
class liveActivitiesCell: UITableViewCell {
@IBOutlet weak var auctionEndsOnLabel: UILabel!
func configureCell(timerClass: timerClass, timer: inout Timer) {
timerClass.getAuctionTime(beginDate: timerClass.beginDate, endDate: timerClass.endDate, _timer: timer, auctionEndsLabelFunc: auctionEndsOnLabel
StartTimerFilter(timer: &timer)
}
@objc func TimerFuncFilter(timerClass: timerClass, timer: Timer) {
print("Timer\(timer)")
timerClass.getAuctionTime(beginDate: timerClass.beginDate, endDate: timerClass.endDate, _timer: timer, auctionEndsLabelFunc: auctionEndsOnLabel)
}
func StartTimerFilter(timer: inout Timer) {
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(liveActivitiesCell.TimerFuncFilter), userInfo: nil, repeats: true)
// DataService.instance.BothDatesReturnedTrue = false
}
JS
if(!$in{type}){
print "content-type: text/html \n\n";
}
elsif($in{type} eq "json"){
print "content-type: application/json \n\n";
}
elsif($in{type} eq "script"){
print "content-type: application/javascript \n\n";
}
,文字回复是
var menuItems;
function getMenuItems(){
$.ajax({
url: "js/sporkAjax.pl",
datatype: "script", /*Also tried json, which wasn't much better*/
data: {func: "getMenuItems", type: "script"},
success: function(data){
menuItems = data;
console.log(data);
}
});
}
答案 0 :(得分:-1)
char* searchBuffer(char* b, int len)
{
unsigned char needle[2] = {0xFF, 0XD9};
char * c;
c = memmem(b, len, needle, sizeof(needle));
return c;
}