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




db photo



1,3 is working fine and access by ajax










share|improve this question






















  • 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















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




db photo



1,3 is working fine and access by ajax










share|improve this question






















  • 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













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




db photo



1,3 is working fine and access by ajax










share|improve this question













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




db photo



1,3 is working fine and access by ajax







jquery ajax codeigniter attributes






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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


















  • 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












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/






share|improve this answer





















    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
    });


    }
    });














    draft saved

    draft discarded


















    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/






    share|improve this answer

























      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/






      share|improve this answer























        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/






        share|improve this answer












        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/







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 at 6:36









        Lekshmi

        95




        95






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Bressuire

            Vorschmack

            Quarantine