[jQuery] Re: jQuery - Ajax and Load question

2009-07-07 Thread BaBna

You need to define your callback function. Maybe something like this?

$.get(index.php, { id: productId , qtd: quantidade }, function(data)
{
  doWhateverWith(data);
});


On Jul 7, 10:42 pm, Glazz brunofgas...@live.com.pt wrote:
 Hello,

 I have a function that have this:

                         $.ajax({
                            type: 'GET',
                            url:  'index.php',
                            data: 'id=' + productId + 'qtd=' + quantidade
                          });

 This piece of code is working great, but i need to know how to get the
 response from the specified url, for example, the response from
 index.php is two, i need to get that to place it inside a div, i know
 with load i can do that, but i want to be able to send in the response
 an array with some data.

 Hope you understand :[

 Regards!


[jQuery] Re: jQuery - Ajax and Load question

2009-07-07 Thread James

with $.ajax, you use the success callback.

$.ajax({
   type: 'GET',
   url:  'index.php',
   data: 'id=' + productId + 'qtd=' +
quantidade,
   success: function(data) {
alert(data);
   },
   error: function() {
alert('error occurred');
   }
 });

On Jul 7, 11:49 am, BaBna thomas.na...@gmail.com wrote:
 You need to define your callback function. Maybe something like this?

 $.get(index.php, { id: productId , qtd: quantidade }, function(data)
 {
   doWhateverWith(data);

 });

 On Jul 7, 10:42 pm, Glazz brunofgas...@live.com.pt wrote:

  Hello,

  I have a function that have this:

                          $.ajax({
                             type: 'GET',
                             url:  'index.php',
                             data: 'id=' + productId + 'qtd=' + quantidade
                           });

  This piece of code is working great, but i need to know how to get the
  response from the specified url, for example, the response from
  index.php is two, i need to get that to place it inside a div, i know
  with load i can do that, but i want to be able to send in the response
  an array with some data.

  Hope you understand :[

  Regards!




[jQuery] Re: jQuery - Ajax and Load question

2009-07-07 Thread Glazz

Thanks for the quick replies, using $.get i can do what i want, with
$.ajax i can too, except the data coming from the .php page is json
encoded so in the $.get i used 'json' at the end - $.get(.., ..,
function(), 'json');

Is there any big difference using $.get or $.post, or just $.ajax and
defining the method ( get or post ) in $.ajax?

On 7 Jul, 22:53, James james.gp@gmail.com wrote:
 with $.ajax, you use the success callback.

                         $.ajax({
                            type: 'GET',
                            url:  'index.php',
                            data: 'id=' + productId + 'qtd=' +
 quantidade,
                            success: function(data) {
                                 alert(data);
                            },
                            error: function() {
                                 alert('error occurred');
                            }
                          });

 On Jul 7, 11:49 am, BaBna thomas.na...@gmail.com wrote:

  You need to define your callback function. Maybe something like this?

  $.get(index.php, { id: productId , qtd: quantidade }, function(data)
  {
    doWhateverWith(data);

  });

  On Jul 7, 10:42 pm, Glazz brunofgas...@live.com.pt wrote:

   Hello,

   I have a function that have this:

                           $.ajax({
                              type: 'GET',
                              url:  'index.php',
                              data: 'id=' + productId + 'qtd=' + quantidade
                            });

   This piece of code is working great, but i need to know how to get the
   response from the specified url, for example, the response from
   index.php is two, i need to get that to place it inside a div, i know
   with load i can do that, but i want to be able to send in the response
   an array with some data.

   Hope you understand :[

   Regards!




[jQuery] Re: jQuery - Ajax and Load question

2009-07-07 Thread Glazz

Ok i got it, just need to use $.ajax({dataType : 'json'});

On 7 Jul, 23:12, Glazz brunofgas...@live.com.pt wrote:
 Thanks for the quick replies, using $.get i can do what i want, with
 $.ajax i can too, except the data coming from the .php page is json
 encoded so in the $.get i used 'json' at the end - $.get(.., ..,
 function(), 'json');

 Is there any big difference using $.get or $.post, or just $.ajax and
 defining the method ( get or post ) in $.ajax?

 On 7 Jul, 22:53, James james.gp@gmail.com wrote:

  with $.ajax, you use the success callback.

                          $.ajax({
                             type: 'GET',
                             url:  'index.php',
                             data: 'id=' + productId + 'qtd=' +
  quantidade,
                             success: function(data) {
                                  alert(data);
                             },
                             error: function() {
                                  alert('error occurred');
                             }
                           });

  On Jul 7, 11:49 am, BaBna thomas.na...@gmail.com wrote:

   You need to define your callback function. Maybe something like this?

   $.get(index.php, { id: productId , qtd: quantidade }, function(data)
   {
     doWhateverWith(data);

   });

   On Jul 7, 10:42 pm, Glazz brunofgas...@live.com.pt wrote:

Hello,

I have a function that have this:

                        $.ajax({
                           type: 'GET',
                           url:  'index.php',
                           data: 'id=' + productId + 'qtd=' + 
quantidade
                         });

This piece of code is working great, but i need to know how to get the
response from the specified url, for example, the response from
index.php is two, i need to get that to place it inside a div, i know
with load i can do that, but i want to be able to send in the response
an array with some data.

Hope you understand :[

Regards!




[jQuery] Re: jQuery - Ajax and Load question

2009-07-07 Thread Cesar Sanz


$.get and $.post are convenient methods
They both utilize $.ajax internally

- Original Message - 
From: Glazz brunofgas...@live.com.pt

To: jQuery (English) jquery-en@googlegroups.com
Sent: Tuesday, July 07, 2009 4:12 PM
Subject: [jQuery] Re: jQuery - Ajax and Load question



Thanks for the quick replies, using $.get i can do what i want, with
$.ajax i can too, except the data coming from the .php page is json
encoded so in the $.get i used 'json' at the end - $.get(.., ..,
function(), 'json');

Is there any big difference using $.get or $.post, or just $.ajax and
defining the method ( get or post ) in $.ajax?

On 7 Jul, 22:53, James james.gp@gmail.com wrote:

with $.ajax, you use the success callback.

$.ajax({
type: 'GET',
url: 'index.php',
data: 'id=' + productId + 'qtd=' +
quantidade,
success: function(data) {
alert(data);
},
error: function() {
alert('error occurred');
}
});

On Jul 7, 11:49 am, BaBna thomas.na...@gmail.com wrote:

 You need to define your callback function. Maybe something like this?

 $.get(index.php, { id: productId , qtd: quantidade }, function(data)
 {
 doWhateverWith(data);

 });

 On Jul 7, 10:42 pm, Glazz brunofgas...@live.com.pt wrote:

  Hello,

  I have a function that have this:

  $.ajax({
  type: 'GET',
  url: 'index.php',
  data: 'id=' + productId + 'qtd=' + quantidade
  });

  This piece of code is working great, but i need to know how to get the
  response from the specified url, for example, the response from
  index.php is two, i need to get that to place it inside a div, i know
  with load i can do that, but i want to be able to send in the response
  an array with some data.

  Hope you understand :[

  Regards!