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.
Related
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';
}
}
});
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.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
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
Closed 9 years ago.
Improve this question
Is it possible to parse an external php file via XMLHttpResquest? If not, how would I exectute an external php file on a page, or load the script into the document?
You would have to make a CURL request from your PHP to a server which is geared to serve raw PHP code rather than execute it. Normally servers don't print the server-side code so you might have some issue there.
You can then use the eval() function to execute raw PHP code
http://php.net/manual/en/function.eval.php
Also, I would recommend finding an alternative to whatever it is you are trying to achieve because, unless you know exactly what you are doing... it sounds wrong.
According to same origin policy you cant . XMLHttpResquest can only call scripts from same server.
But there is a hook for this. I dont know how exactly you do this in core javascript, but in jQuery you can do something like this:
var aURL="SOME_EXTERNAL_URL";
$.ajax({
url: aURL+"&callback=?",
data: "message="+commentdata,
type: 'POST',
success: function (resp) {
alert(resp);
},
error: function(e) {
alert('Error: '+e);
}
});
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 5 years ago.
Improve this question
I want to create a dashboard for a bespoke web service we have so that we can monitor usage on a real-time basis. Something similar to the couchbase dashboard if you have seen that. If not, its basically a line graph that scrolls right to left with time along the bottom of the graph and usage on the y-axis.
To minimise data bandwidth I am assuming there is a way to pass just the changed data to update a graph rather than sending a new image/vector each time. And this would get drawn with a javascript charting library.
What I am unclear on is how to get the data from the server. Is the normal approach to have the javascript code poll the server using AJAX every second (if you are after second by second updates) or is some other method used?
I used PHP for the back end and HTML/JS for the client end.
And does anyone have any examples or links that could be helpful.
For getting the data from the backend, I think you can call it using Ajax, reload each second using setInterval(), making something looks like:
setInterval(function() {
$.ajax({
url: url of your backend server,
type: 'GET',
success: function (data) {
//data returned from the server, use it to draw your chart
}
});
}, 1000); // recall ajax every second
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Is it possible to create a auction site in PHP using AJAX to refresh the page once a user has entered a higher amount of money.
I can handle the PHP side of it okay but I was wondering if AJAX can really be used so that it refreshes often without putting a lot of strain on server resources?
I also plan to use JQuery to implement AJAX as this makes the job a whole lot easier. Anybody have any code examples that you think could be used?
Any help would be appreciated/
Thanks!
var currentHighestBid=0;
setTimeOut(getHighestBid,5000); //5000ms wait before polling for a better price
function getHighestBid()
{
$.ajax(
url: url, // ur php end point,
type: "GET"
data: {} //json data if you want to send anything as a querystring parameter to your servre
dataType:"json"
success: function(response)
{
if(response.currentMaxBid>currentHighestBid)
{
currentHighestBid=response.currentMaxBid;
//code to update your markup
}
}
});
Hope that made sense..
Read abt json in php
Polling would work as "zzzz" mentioned. Comet (Push based instead of Polling) would be a nicer/better solution for this use case. However PHP is not really good at this with high traffic sites. Node.JS with Socket.IO would be a good solution for you :)