how to skip bracket from the name in HTML data attribute jquery
up vote
0
down vote
favorite
HTML part
<button class="add_cart btn-success btn-block" data-productname="<?php echo $row->item_name;?>" >Add To Cart</button>
JQuery part
<script type="text/javascript">
$(document).ready(function(){
$('.add_cart').click(function(){
var product_name = $(this).data("productname");
$.ajax({
url : "<?php echo site_url('Product/add_to_cart');?>",
method : "POST",
data : {product_name: product_name},
success: function(data){
$('#detail_cart').html(data);
}
});
});
});
according to the above code (codeigniter view file code)
Here, We were using html data attribute to get the product name from html and pass the product name into jquery ajax,That product name came from database.
The Error is that product name (which fetch from db) some of product name is perfectly working fine to ajax and some of may not
product name contain bracket that name we can't access by ajax.
example
1,3 is working fine and access by ajax
jquery ajax codeigniter attributes
add a comment |
up vote
0
down vote
favorite
HTML part
<button class="add_cart btn-success btn-block" data-productname="<?php echo $row->item_name;?>" >Add To Cart</button>
JQuery part
<script type="text/javascript">
$(document).ready(function(){
$('.add_cart').click(function(){
var product_name = $(this).data("productname");
$.ajax({
url : "<?php echo site_url('Product/add_to_cart');?>",
method : "POST",
data : {product_name: product_name},
success: function(data){
$('#detail_cart').html(data);
}
});
});
});
according to the above code (codeigniter view file code)
Here, We were using html data attribute to get the product name from html and pass the product name into jquery ajax,That product name came from database.
The Error is that product name (which fetch from db) some of product name is perfectly working fine to ajax and some of may not
product name contain bracket that name we can't access by ajax.
example
1,3 is working fine and access by ajax
jquery ajax codeigniter attributes
data-productname="'<?php echo $row->item_name;?>'"
?
– guradio
Nov 12 at 6:13
codeigniter shopping cart class doesn't allow any special character in the name.
– Yadhu Babu
Nov 12 at 6:14
Thank you for your response @YadhuBabu , Ok then How to solve that issue ?
– kobi
Nov 12 at 6:17
Just wondering why you wouldn't be passing the items id instead of its name if you are using that to add something to a database?
– TimBrownlaw
Nov 12 at 9:42
@TimBrownlaw Thank you for you response.Ya you are but I want know if there simple way to sort it <3
– kobi
Nov 12 at 10:15
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
HTML part
<button class="add_cart btn-success btn-block" data-productname="<?php echo $row->item_name;?>" >Add To Cart</button>
JQuery part
<script type="text/javascript">
$(document).ready(function(){
$('.add_cart').click(function(){
var product_name = $(this).data("productname");
$.ajax({
url : "<?php echo site_url('Product/add_to_cart');?>",
method : "POST",
data : {product_name: product_name},
success: function(data){
$('#detail_cart').html(data);
}
});
});
});
according to the above code (codeigniter view file code)
Here, We were using html data attribute to get the product name from html and pass the product name into jquery ajax,That product name came from database.
The Error is that product name (which fetch from db) some of product name is perfectly working fine to ajax and some of may not
product name contain bracket that name we can't access by ajax.
example
1,3 is working fine and access by ajax
jquery ajax codeigniter attributes
HTML part
<button class="add_cart btn-success btn-block" data-productname="<?php echo $row->item_name;?>" >Add To Cart</button>
JQuery part
<script type="text/javascript">
$(document).ready(function(){
$('.add_cart').click(function(){
var product_name = $(this).data("productname");
$.ajax({
url : "<?php echo site_url('Product/add_to_cart');?>",
method : "POST",
data : {product_name: product_name},
success: function(data){
$('#detail_cart').html(data);
}
});
});
});
according to the above code (codeigniter view file code)
Here, We were using html data attribute to get the product name from html and pass the product name into jquery ajax,That product name came from database.
The Error is that product name (which fetch from db) some of product name is perfectly working fine to ajax and some of may not
product name contain bracket that name we can't access by ajax.
example
1,3 is working fine and access by ajax
jquery ajax codeigniter attributes
jquery ajax codeigniter attributes
asked Nov 12 at 6:09
kobi
8112
8112
data-productname="'<?php echo $row->item_name;?>'"
?
– guradio
Nov 12 at 6:13
codeigniter shopping cart class doesn't allow any special character in the name.
– Yadhu Babu
Nov 12 at 6:14
Thank you for your response @YadhuBabu , Ok then How to solve that issue ?
– kobi
Nov 12 at 6:17
Just wondering why you wouldn't be passing the items id instead of its name if you are using that to add something to a database?
– TimBrownlaw
Nov 12 at 9:42
@TimBrownlaw Thank you for you response.Ya you are but I want know if there simple way to sort it <3
– kobi
Nov 12 at 10:15
add a comment |
data-productname="'<?php echo $row->item_name;?>'"
?
– guradio
Nov 12 at 6:13
codeigniter shopping cart class doesn't allow any special character in the name.
– Yadhu Babu
Nov 12 at 6:14
Thank you for your response @YadhuBabu , Ok then How to solve that issue ?
– kobi
Nov 12 at 6:17
Just wondering why you wouldn't be passing the items id instead of its name if you are using that to add something to a database?
– TimBrownlaw
Nov 12 at 9:42
@TimBrownlaw Thank you for you response.Ya you are but I want know if there simple way to sort it <3
– kobi
Nov 12 at 10:15
data-productname="'<?php echo $row->item_name;?>'"
?– guradio
Nov 12 at 6:13
data-productname="'<?php echo $row->item_name;?>'"
?– guradio
Nov 12 at 6:13
codeigniter shopping cart class doesn't allow any special character in the name.
– Yadhu Babu
Nov 12 at 6:14
codeigniter shopping cart class doesn't allow any special character in the name.
– Yadhu Babu
Nov 12 at 6:14
Thank you for your response @YadhuBabu , Ok then How to solve that issue ?
– kobi
Nov 12 at 6:17
Thank you for your response @YadhuBabu , Ok then How to solve that issue ?
– kobi
Nov 12 at 6:17
Just wondering why you wouldn't be passing the items id instead of its name if you are using that to add something to a database?
– TimBrownlaw
Nov 12 at 9:42
Just wondering why you wouldn't be passing the items id instead of its name if you are using that to add something to a database?
– TimBrownlaw
Nov 12 at 9:42
@TimBrownlaw Thank you for you response.Ya you are but I want know if there simple way to sort it <3
– kobi
Nov 12 at 10:15
@TimBrownlaw Thank you for you response.Ya you are but I want know if there simple way to sort it <3
– kobi
Nov 12 at 10:15
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
You can alter the product name rule after creating My_Cart.php
in applicationlibraries with this code:
var $product_name_rules = 'dD';
See this link for more options
http://ponderwell.net/2010/07/codeigniter-extending-the-cart-class-for-robust-product-names/
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256700%2fhow-to-skip-bracket-from-the-name-in-html-data-attribute-jquery%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You can alter the product name rule after creating My_Cart.php
in applicationlibraries with this code:
var $product_name_rules = 'dD';
See this link for more options
http://ponderwell.net/2010/07/codeigniter-extending-the-cart-class-for-robust-product-names/
add a comment |
up vote
0
down vote
You can alter the product name rule after creating My_Cart.php
in applicationlibraries with this code:
var $product_name_rules = 'dD';
See this link for more options
http://ponderwell.net/2010/07/codeigniter-extending-the-cart-class-for-robust-product-names/
add a comment |
up vote
0
down vote
up vote
0
down vote
You can alter the product name rule after creating My_Cart.php
in applicationlibraries with this code:
var $product_name_rules = 'dD';
See this link for more options
http://ponderwell.net/2010/07/codeigniter-extending-the-cart-class-for-robust-product-names/
You can alter the product name rule after creating My_Cart.php
in applicationlibraries with this code:
var $product_name_rules = 'dD';
See this link for more options
http://ponderwell.net/2010/07/codeigniter-extending-the-cart-class-for-robust-product-names/
answered Nov 12 at 6:36
Lekshmi
95
95
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256700%2fhow-to-skip-bracket-from-the-name-in-html-data-attribute-jquery%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
data-productname="'<?php echo $row->item_name;?>'"
?– guradio
Nov 12 at 6:13
codeigniter shopping cart class doesn't allow any special character in the name.
– Yadhu Babu
Nov 12 at 6:14
Thank you for your response @YadhuBabu , Ok then How to solve that issue ?
– kobi
Nov 12 at 6:17
Just wondering why you wouldn't be passing the items id instead of its name if you are using that to add something to a database?
– TimBrownlaw
Nov 12 at 9:42
@TimBrownlaw Thank you for you response.Ya you are but I want know if there simple way to sort it <3
– kobi
Nov 12 at 10:15