Web Design Forum: Jquery Ajax URL - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Jquery Ajax URL Rate Topic: -----

#1 User is offline   benhawk 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 20-June 10
  • Reputation: 3
  • Gender:Male
  • Location:UK
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 30 January 2012 - 08:19 PM

Hi,

Im building an application using codeigniter which uses some ajax.

Here is the ajax call I am making

$.ajax({
  		  type: 'get',
  		  url: '<?php echo base_url(); ?>index.php/booking/addDriver',
  		  data: '/1/2/',
  		  beforeSend: function() {
  		  },
  		  success: function() {
  		  	dragged.parentNode.removeChild(dragged);
  		  }
  		});


From this I want to generate the URL

http://localhost/TaxiBooking/index.php/booking/addDriver/1/2/


However it keeps generating

http://localhost/TaxiBooking/index.php/booking/addDriver?/1/2/


The URL part of the AJAX keeps adding the ? mark at the end which is not required for codeigniter and brakes the call

Anyone know how I can stop the URL doing this :(

Thanks
0

#2 User is online   andyl 

  • White space enthusiast
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,535
  • Joined: 21-January 10
  • Reputation: 210
  • Gender:Male
  • Location:Surrey
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 30 January 2012 - 08:22 PM

So just use:

$.ajax({
  type: 'get',
  url: '<?= base_url(); ?>index.php/booking/addDriver/1/2',
  beforeSend: function() {
  },
  success: function() {
        dragged.parentNode.removeChild(dragged);
  }
});

1

#3 User is offline   benhawk 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 20-June 10
  • Reputation: 3
  • Gender:Male
  • Location:UK
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 30 January 2012 - 08:34 PM

View Postandyl, on 30 January 2012 - 08:22 PM, said:

So just use:

$.ajax({
  type: 'get',
  url: '<?= base_url(); ?>index.php/booking/addDriver/1/2',
  beforeSend: function() {
  },
  success: function() {
        dragged.parentNode.removeChild(dragged);
  }
});



Brilliant thanks mate!
0

#4 User is online   Spitfire 

  • Mighty Pirate™
  • PipPipPipPip
  • Group: Members
  • Posts: 891
  • Joined: 05-February 11
  • Reputation: 189
  • Gender:Male
  • Location:Berkshire
  • Experience:Web Guru
  • Area of Expertise:Web Developer

Posted 30 January 2012 - 09:04 PM

You could also try:
$.ajax({
	type: 'get',
	url: '<?php echo base_url(); ?>index.php/booking/addDriver',
	data: '/1/2/',
	processData: false,
	beforeSend: function() {
	},
	success: function() {
		dragged.parentNode.removeChild(dragged);
	}
});


Which should stop the data being automatically converted into a GET request key/value pairs.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users