Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I start a new mobile application using jQuery Mobile.
Basically it will pull Events and Gallery from Facebook.
1.Normal PHP files will be on server and I will just make a Ajax request to them.
Like this:
$.ajax({
type:"POST",
url : "www.example.com/example.php",
data : somedata,
dataType : 'json',
2.If I will make it like this with no Internet connetion it will show error.
There is a way to save(cache) the last call to server?
And if new call is made and ther is no Internet Conenction or Bad Request or any other error and empty response, show the latest good response!
Thank you for any suggestions.
1.It is normal if PHP files will be on server and I will just make a Ajax request to them.?
Sure it is.
2.There is a way to save(cache) the last opretaions?
Of course. You could try the HTML5 application cache, or other server-side (PHP) methods.
Related
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 8 years ago.
Improve this question
I want to update a division of my webpage updated frequently. But the contents of the division is to be loaded from another file on the server which is unable to be accessed from the file. I have made the access for the first time through PHP on the server. When I'm updating the information, the javascript is on client-side and I'm unable to access it.Also, the meta tag refreshes the entire webpage. I just want to update the division
What are the ways to solve this problem?
You could do this with jQuery and AJAX
like this:
$.get('/route/to/file', { args }, function(data) {
$('#some-container').html(data);
});
If you need it to be fully realtime, you could also use Socket.io:
var ws = io( ... );
ws.on('some.realtime.event', function(data) {
$('#some-container').html(data);
});
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am trying to understand what medium to use to fetch data from a MySQL database using PHP.
What is better "speed" wise, jQUERY or PHP to fetch data form MySQL on page load?
With jQuery alone you can't fetch data from mysql.
If your question is to load with the page or get the data from php after loading, I can say, that loading with page is better, because the text is standing on the page when you load it and jquery will have a delay to display the data.
$.ajax({url: 'ajax.php', success: function(data){$('#name').text(data.name)}});
When you use jQuery, you ask PHP (or other technology as .NET, ...) to fetch the data from MySQL.
In terms of usability... it depends. Perhaps you want to load your web/application schema and after that use jQuery to load the information (so the web seems to load faster). But, as I said, you will use PHP. The difference is that you can have a PHP file to build the schema and another PHP to retrieve the information.
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 8 years ago.
Improve this question
I've succeed to install Zend Developer Tools and get it work , but i have an issue is the queries called using Ajax doesn't show in the bar.is that a way to fix that ?
You can use Zend Studio. This is a great tool to develop in using ZF. Here is a link Alternatively you can check browser console window to check how long a request takes but this will not show actual db interaction time. For that you have to calculate time on your own and return with the request. And then you can console.log that response.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have a PHP page that retrieves a list from the DB, and I want to display it on a loaded page using Ajax.
Should I format it on the PHP side (HTML formatting), and just retrieve the data, or pass it to JS like dataA:dataB:dataC and format it client-side?
there won't be a lot of people using it, but I would like to know which is better (if there is a better method without taking the amount of users into account)
Both will work fine. However in my opinion if you're gonna use ajax - and transfer information - a better practice will be to wrap the data in JSON format and parse it on the client's machine.
Example of the php output:
{
"row1":{"field1":"value11", "field2":"value12"}
"row2":{"field2":"value21", "field2":"value22"}
...
}
Exmaple of parsing:
$.ajax(...).done(function(result){
$.each(result, function(index,value){
$('#conatiner').append('<div>'+index+': field1='+value.field1+', field2='+value.field2+'</div>')
})
});
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have an img with a link of a request next every reply in one post. and it allow the author of the post to select the right answer. if you clicked on the img it will do a request...
the request will update the reply to be the right answer reply (* similar to stackoverflow.com)
the problem is when I do that, it always send me to the top of the page. I think it refreshs.
I want to avoid refreshing or sending me to the top of the page. I want it to do nothing but the request.
some people told me the solution is javascript. but how ? because I can't with javascript do requests nor sql updates ... ?
JavaScript can make requests to the server without refreshing the page. Usually, a library such as jQuery is used to make the process easier.
In your example, JavaScript needs to do two things:
Tell the server (php/mysql) what answer was selected as correct so that future visitors see the change
Update the client (browser) to show the change.
That should be enough to get you started - you are going to need to learn quite a bit. Read the docs at jquery.com and search for code examples.