[RESOLVED] JSON Not letting me post a URL?
How do you all a URL to pass thru json?
http:// is breaking it... im guessing its the // because if I remove one it works...
Code:
$('#save_social').click(function() {
$('.wait').show();
$('.wait').fadeIn(400).html('<img src="images/loading.gif" />');
var user_fb=$('#fb_name').val();
var user_tw=$('#tw_name').val();
var user_id=$('#usrid').val();
$.ajax({
type: "POST",
url: "functions/soc.php",
data: { fb: user_fb, tw: user_tw, uid: user_id },
dataType: "json",
cache: false,
success: function(result){
if(result.stat=='fail'){
$('.wait').addClass("red");
$('.wait').fadeIn(400).html(result.query);
}else{
$('.wait').removeClass("red");
$('.wait').fadeIn(400).html("");
$('#edit_user').hide();
}
}
});
});
Re: JSON Not letting me post a URL?
I don't think php passes different than asp.net, as i pass it in the same way (for a service "myservice.svc/getfunction"). I am not sure though how would you pass this on remote domains. I think http:// is needed there + more stuff. So I am not sure on what of these your are trying here.
Re: JSON Not letting me post a URL?
Are you saying that you want to specify http:// here?
Code:
url: "functions/soc.php",
Re: JSON Not letting me post a URL?
JSON isn't the issue.
This is the JSON here: { fb: user_fb, tw: user_tw, uid: user_id }
There's no URL in there anywhere. If you're talking about the same segment that szlamany is talking about "url: "functions/soc.php" that's just JS/AJAX, has nothing to do with JSON.
I think you're going to need to be a little more specific in your description.
-tg
Re: JSON Not letting me post a URL?
no lol
the VALUE of var user_fb=$('#fb_name').val(); will be a URL
so it breaks it as it tries to pass the url through json to the php... its like I need to escape the /'s but cant seem to make that work?
Re: JSON Not letting me post a URL?
Re: JSON Not letting me post a URL?
I never have to deal with escaping data coming from the browser - have to worry about it the other way around.
Where is the error you are getting? What error? Backend error? JS blowing up?
Re: JSON Not letting me post a URL?
I am not running it in a debugger :D , but the JS is stopping right at the point it needs to send the data to the php file...
I will try encoding it...if you remove one / it works. http:/blah.blah - so its seeing the // as something odd
Re: JSON Not letting me post a URL?
well, can you assume the http:// ? I'm wondering if maybe you simply strip http:// off of the URL, send it over, then on the server add the http:// back in. Just a thought.
-tg
Re: JSON Not letting me post a URL?
:blush::rolleyes:
well... I suppose that might work.... Im going to go drink now. lol