How to set a new value for data-url attribute using jquery?

0 votes

Before page load:

<a data-url="htts://xyz@..." class="mybuttons"  data-type="facebook">

After: On page load using jquery I used to append new data-url

<a data-url="https://abc@..." class="mybuttons"  data-type="facebook">

Now when I want to share this new data url using facebook api then it show old url https://xyz@... in url bar.

I want new data-url to be shared.

I have successfully change the data-url using $(this).attr('data-url',value.url). What to do please help me out. Even my new data-url is not getting show in page source.

Apr 14 in Laravel by kartik
• 20,880 points
201 views

1 answer to this question.

0 votes

Hii,

In your line:

$(this).attr('data-url',value.url);

are you sure this refers to the right DOM object?

Try adding an id to the anchor:

<a id='face-url' data-url="htts://xyz@..." class="mybuttons"  data-type="facebook">

Then in your code, set the data-url attribute this way:

$('#face-url').data('url', value.url);

Now that you have set the attribute value, you have to be sure that the facebook API reads this attribute only after you've changed it.

Hope this work!!

Thank You!!

answered Apr 14 by Niroj
• 44,600 points

Related Questions In Laravel

0 votes
1 answer
0 votes
1 answer

How to pass data through URL and access through controller in Laravel?

Hello, You can  first refer how to  Create controller through ...READ MORE

answered Mar 18 in Laravel by Niroj
• 44,600 points
873 views
0 votes
1 answer

.How to turn off CSRF protection for a particular route in Laravel?

Hey, We can add that particular URL or ...READ MORE

answered Mar 24 in Laravel by Niroj
• 44,600 points
392 views
0 votes
1 answer

How to add a new column to existing table of laravel in a migration?

Hii @kartik, To create a migration, you may ...READ MORE

answered Mar 30 in Laravel by Niroj
• 44,600 points
5,157 views
0 votes
1 answer

What is Laravel framework? Why one should use Laravel?

Laravel is a PHP web-framework; it utilized ...READ MORE

answered Mar 17 in Laravel by Niroj
• 44,600 points
118 views
0 votes
1 answer

How to download and install Lavavel framework?

Hey @kartik, First you must have xampp install ...READ MORE

answered Mar 17 in Laravel by Niroj
• 44,600 points
125 views
0 votes
1 answer

How can we get started with Laravel through Xampp?

Hii, First you need to start Apache and ...READ MORE

answered Mar 17 in Laravel by Niroj
• 44,600 points
54 views
0 votes
1 answer

What are the important directories used in a common Laravel application

Hey @Kartik. Directories used in a common Laravel ...READ MORE

answered Mar 17 in Laravel by Niroj
• 44,600 points
58 views
0 votes
1 answer

How to make a new page with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18 in Laravel by Niroj
• 44,600 points
100 views
0 votes
1 answer

How Can I Set the Default Value of a Timestamp Column to the Current Timestamp with Laravel Migrations?

Hello, To create both of the created_at and updated_at columns: $t->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP')); $t->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP on update ...READ MORE

answered Apr 2 in Laravel by Niroj
• 44,600 points
1,196 views