请通过以下Jquery方法返回脚本字符串,在那里我想删除处理程序键值(这是函数)的双引号
_GetOptionsScrpit: function () {
var sb = [];
var self = this;
var o = self.options;
sb.push({
"key": o.key,
"amount": o.amount,
"name": o.name,
"description": o.description,
"image": o.image,
"order_id":o.order_id,
"handler": 'function(response) {alert(response)}',
"prefill": {
"name": o.prefillname,
"email": o.prefillemail,
"contact": o.prefillcontact,
"method": self._GetDefaultPrefilMethod()
},
//"notes": o.notes,
"theme": {
"color": o.color
},
"method": {
"netbanking": o.IsNetbanking,
"wallet": o.IsWallet,
"card": o.IsCard,
"upi": o.IsUPI
},
"modal": {
"escape": o.modalescape,
"backdropclose": o.modalbackdropclose
},
});
return '<script type="text/javascript"> var options = ' + JSON.stringify(sb[0]) + ' ;';
console.log('<script type="text/javascript"> var options = ' + JSON.stringify(sb[0]) + ' ;');
}
方法正在返回
<script type="text/javascript">
var options = {
"key": "rzp_test_Mh1t1NPPlSbufV",
"amount": "10000",
"name": "Merchant Name",
"description": "Purchase Description",
"image": "https://your-awesome-site.com/your_logo.jpg",
"order_id": "",
"handler": "function(response) {alert(response)}",
"prefill": {
"name": "ggg",
"email": "ggg@ggg.com",
"contact": "9441239494",
"method": "netbanking"
},
"theme": {
"color": ""
},
"method": {
"netbanking": "true",
"wallet": "false",
"card": "false",
"upi": false
},
"modal": {
"escape": true,
"backdropclose": true
}
};
var rzp1 = new Razorpay(options);
document.getElementById("rzp-button1").onclick = function(e) {
rzp1.open();
e.preventDefault()
};
请确实需要完整,我需要输出如下(处理程序值没有双引号)
<script type="text/javascript">
var options = {
"key": "rzp_test_Mh1t1NPPlSbufV",
"amount": "10000",
"name": "Merchant Name",
"description": "Purchase Description",
"image": "https://your-awesome-site.com/your_logo.jpg",
"order_id": "",
"handler": function(response) {alert(response)},
"prefill": {
"name": "ggg",
"email": "ggg@ggg.com",
"contact": "9441239494",
"method": "netbanking"
},
"theme": {
"color": ""
},
"method": {
"netbanking": "true",
"wallet": "false",
"card": "false",
"upi": false
},
"modal": {
"escape": true,
"backdropclose": true
}
};
var rzp1 = new Razorpay(options);
document.getElementById("rzp-button1").onclick = function(e) {
rzp1.open();
e.preventDefault()
};