Simultaneously adding points and linking [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
i got this simple points system, where when a user clicks on the image it adds 20 points to the database through a mysql query. It works, however, I'm trying to make it so that when a user clicks on the image that it not only adds points to a users database but also goes to a website. I added correctly but then it links but doesn't add points. Any help would be appreciated.

Use Ajax for inserting points in your database and after response(in your success method) send it to your desired URL.
$.ajax({
type: "POST",
url: '/test/points.php',
data: formData,
success: function (dataCheck) {
if (dataCheck) {
window.location = 'www.example.com';
}
}
});

Related

using ajax url to call php file [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Cant seem to connect the ajax url to a php file. I've been fiddling around for ages.
File path of JavaScript: h******ze.com/public_html/wp-content/themes/buddyboss-theme-child/assets/js
needs to be be linked to file path PHP:
h******ze.com/public_html/wp-content/plugins/buddyboss-platform/bp-templates/bp-nouveau/buddypress/activity/user-duration.php
setInterval(function(){
$.ajax({
url: '/public_html/wp-content/plugins/buddyboss-platform/bp-templates/bp-nouveau/buddypress/activity/user-duration.php',
success: function(data) {
$('.result').html(data);
}
});
}, 3000);
Assuming the website is visible at h???????ze.com and not h??????ze.com/public_html your URL should be /wp-content/plugins/buddyboss-platform/bp-templates/bp-nouveau/buddypress/activity/user-duration.php
public_html is the root of your website and will contain index.php so you need to point it there. The browser has no access to anything before this in the URL you are using.

php - redirect ajax requests [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
How can I redirect an ajax request in php/wordpress.
I tried header("Location: " . "http://redirect.url"); but it doesn't work, the response has 301 Moved Permanently status and the request fails.
You cannot redirect from php by an ajax request. Instead of that you need to do it inside your javascript.
For example if this is your ajax then after success of your request redirect from ajax itself
$.ajax({
type : 'post',
url : 'http://localhost/redirect.php',
success : function(data){
window.location = "http://your/url";
}
});

Open jquery modal on Success AJAX [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I want to alert the user that their action is successful when they click the button, here is my code. Please Help. Thanks in advance.
<script type="text/javascript">
function postck3() {
$.post('insert_home.php', {
INSERT_WELCOME: CKEDITOR.instances.CKWELCOME.getData()
});
}
</script>
Try
$.post('insert_home.php',{INSERT_WELCOME:editor_data3}).done(function(data){
alert("Success data return ed from server is "+ data);
});

Load information to a div based on a click from another div [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
This is probably terribly simple. I have done something similar to this when the information was being passed to a different page.
Basically... I have a div with a dynamically generated list of objects.
<li><?= $array['City'] ?></li>
All of the code already exists to load the zip codes for a given city, so in PHP (in this case)
$locations = new ProjectsLocationsArrays();
$zipcodes = $locations->array_zips($array['City']);
At present, everything runs off of query strings... ?city=aaa&zip=123, seems sloppy to me. I would like to use AJAX. Once the cities are loaded, how do I load the zips into an existing div on the page, fired by a click on one of the city anchors.
TIA
If you have jQuery something like this should work
function loadZipCodes(city){
$.ajax({
url: "pagethatgivesarrayofzipcodes.php",
method: "POST",
data : {'city': city}
}).done(function(data) {
$(.zip-div).html(data);
});
}
Where pagethatgivesarrayofzipcodes.php takes a $_POST['city'] containing the city info and returns either HTML or a a Javascript array of ZIP codes.

how change url when use $.ajax and title and [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
i use this code cuz i dont want my header or my footer bar load in every page
$('a#load').click(function(autoload){
autoload.preventDefault();
var location = $(this).attr('href');
var base = $(this).attr('base');
var id = $(this).attr('more-data');
if(base === 'basic'){
$.ajax({
url: location,
data: { },
success: function(result) {
$("#content").html(result);
}
});
}//if base
});
but how i can change URL in address bar for seo? and how change title of that page? or/and keywords ?
its possible?
its must be cuz in facebook we see ajax load without load header and chat bar in footer
and if facebook use another method please give me a example how use ajax load for best SEO - speed
thank you :)
Stuff you do in JavaScript generally doesn't do anything for you SEO-wise. Facebook loads content via AJAX to speed things up for users browsing around the site, but there's plain-old-static-HTML loadable versions of those URLs too - that's what Google indexes.
Facebook et. al. do this with the HTML5 history/state APIs. There's a ready-made library called History.js that's handy for this.

Categories